/** * Represents the empty list. Uses the Singleton pattern to model the * uniqueness of the empty list. * @author Dung X. Nguyen * @version 1.1 * @since 01/25/02 * @Custom Copyright 2002 -All rights reserved */ public class EmptyList extends AList { /** * Singleton pattern. */ public final static EmptyList Singleton = new EmptyList(); /** * Disables public instantiation of EmptyList. */ private EmptyList() { } /** * Throws an IllegalArgumentException. * @return does not return. * @exception IllegalArgumentException. */ public Object getFirst() { throw new IllegalArgumentException ("EmptyList has no first!"); } /** * Throws an IllegalArgumentException * @return does not return. * @exception IllegalArgumentException. */ public AList getRest() { throw new IllegalArgumentException ("EmptyList has no rest!"); } /** * Computes a String representation of this EmptyList. * @return "()". */ public String toString() { return "()"; } /** * Computes the length of this EmptyList. * @return 0 */ public int getLength() { return 0; } }