package listFW.visitor; import listFW.*; /** * Concatenates the host with the input parameter. * An IListFactory is passed to the constructor. * @author D.X. Nguyen * @since Copyright 2002 DXN - All rights reserved */ public class ConcatWith implements IListAlgo{ private IListFactory _fact; public ConcatWith (IListFactory f) { _fact = f; } /** * Returns the input list since the host is empty. * @param host an IEmptyList. * @param rhs IList on the right hand side. * @return rhs */ public Object emptyCase(IEmptyList host, Object rhs) { return rhs; } /** * Cons host's first with the concatenation of host's rest. * @param host an INEList. * @param rhs IList on the right hand side * @return INEList */ public Object nonEmptyCase(INEList host, Object rhs) { IList restConcat = (IList)host.getRest ().execute (this, rhs); return _fact.makeNEList(host.getFirst (), restConcat); } }