package list.visitor; import list.*; public class MakeClone implements IListAlgo { public final static MakeClone Singleton = new MakeClone(); private MakeClone() { } /** *Returns an empty list. * host receives and empty list * input receives null */ public Object forEmpty(AList host, Object input) { return ListFactory.Singleton.makeEmptyList(); } /** * Returns an exact copy of the list * host receives and a list * input receives null */ public Object forNonEmpty(AList host, Object input) { return ListFactory.Singleton.makeNEList(host.getFirst(), (AList)host.getRest().execute(this, null)); } }