EmptyList.java
Created with JBuilder
package OOscheme;
/**
 * Represents the empty list.
 * @author Dung X. Nguyen
 * @version 2.0
 * @since 01/31/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!");
    }

    /**
     * Calls algo's empty case method.
     */
    public Object execute(IListAlgo algo, Object inp) {
        return algo.emptyCase(this, inp);
    }
}



EmptyList.java
Created with JBuilder