001 package listFW.visitor;
002
003 import listFW.*;
004
005 /**
006 * Append another list, passed as input[0], at the end of this list.
007 */
008 public class Append<T> implements IListAlgo<T,IList<T>,IList<T>> {
009 private IListFactory<T> _fac;
010
011 public Append(IListFactory<T> fac) {
012 _fac = fac;
013 }
014
015 /**
016 * Returns the input list.
017 * @param input input[0] is the list to append.
018 */
019 public IList<T> emptyCase(IMTList<? extends T> host, IList<T>... input) {
020 return input[0];
021 }
022
023 /**
024 * Returns the appended lists.
025 * @param input input[0] is the list to append.
026 */
027 public IList<T> nonEmptyCase(INEList<? extends T> host, IList<T>... input) {
028 return _fac.makeNEList(host.getFirst(),
029 host.getRest().execute(this, input));
030 }
031 }