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 nu not used * @return does not return. * @exception IllegalArgumentException */ public Object emptyCase(IEmptyList host, Object... nu) { throw new IllegalArgumentException("GetMin called on EmptyList, which 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 nu not used * @return Integer */ public Object nonEmptyCase(INEList host, Object... nu) { return host.getRest().execute(GetMinHelper.Singleton, host.getFirst()); } }