001 package listFW.visitor; 002 003 import listFW.*; 004 005 /** 006 * Copies an IList<T> using the supplied IListFactory<T> 007 * @author Mathias Ricken - Copyright 2008 - All rights reserved. 008 */ 009 public class CopyList2<T> implements IListAlgo<T,IList<T>, Void> { 010 private IListFactory<T> fac; 011 012 public CopyList2(IListFactory<T> fac) { 013 this.fac = fac; 014 } 015 016 public IMTList<T> emptyCase(IMTList<? extends T> host, Void... nu) { 017 return fac.makeEmptyList(); 018 } 019 public INEList<T> nonEmptyCase(INEList<? extends T> host, Void... nu) { 020 return fac.makeNEList( host.getFirst(), host.getRest().execute(this)); 021 } 022 }