GetMin.java
Created with JBuilder

package OOscheme.Visitor;
import OOscheme.*;

/**
 * Assumes the AList host contains Integer, computes the minimum of the all
 * the Integer objects in the host.
 */
public class GetMin implements IListAlgo {
    /**
     * Singleton Pattern.
     */
    public static final GetMin Singleton = new GetMin();
    private GetMin() {
    }

    /**
     * Throws an IllegalArgumentException.
     * @param host an EmptyList
     * @param inp not used
     * @return does not return.
     * @exception IllegalArgumentException
     */
    public Object emptyCase(AList host, Object inp) {
        throw new IllegalArgumentException("EmptyList has no data!");
    }

    /**
     * Passes the host's data to the host's rest and asks for help to compute
     * the minimum element in the host.
     * @param host an NEList
     * @param inp not used
     * @return Integer
     */
    public Object nonEmptyCase(AList host, Object inp) {
        return host.getRest().execute(GetMinHelper.Singleton, host.getFirst());
    }
}



GetMin.java
Created with JBuilder