package list; /** * Represents the empty list. * Implemented as a singleton. * * @author Dung X. Nguyen * @version 1.0 * @since 09/10/00 * @Custom Copyright 2000 -All rights reserved */ class EmptyList extends AList { public final static EmptyList Singleton = new EmptyList (); /** * NOTE: The constructor is private so that no client can * instantiate an EmptyList. I.e., there is one "true" empty list, * Singleton, and every list uses it. */ private EmptyList() { } /** * Throws an IllegalArgumentException. * @return does not return. */ public Object getFirst() { throw new java.util.NoSuchElementException ("Empty has no element."); } /** * Throws an IllegalArgumentException. * @return does not return. */ public AList getRest() { throw new java.util.NoSuchElementException ("Empty has no tail."); } /** * @param input */ public Object execute(IListAlgo algo, Object input) { return algo.forEmpty (this, input); } }