package listadt; import java.util.function.Function; /** * This represents an empty node of the generic list implementation. */ public class GenericEmptyNode implements GenericListADTNode { @Override public int count(){return 0;} @Override public GenericListADTNode addFront(T object) { return new GenericElementNode(object,this); } @Override public GenericListADTNode addBack(T object) { return addFront(object);} @Override public GenericListADTNode add(int index,T object) throws IllegalArgumentException { if (index==0){ return addFront(object); } throw new IllegalArgumentException("Invalid index to add an element"); } @Override public GenericListADTNode remove(T object) { return this; //cannot remove from nothing! } @Override public T get(int index) throws IllegalArgumentException { throw new IllegalArgumentException("Wrong index"); } @Override public GenericListADTNode map(Function converter) { return new GenericEmptyNode(); } @Override public String toString() { return "";} }