package list; /** * Manufactures AList objects. * Implemented as a singleton. * * @author Dung X. Nguyen * @version 1.0 * @since 09/17/00 * @Custom Copyright 2000 -All rights reserved */ public class ListFactory { public final static ListFactory Singleton = new ListFactory (); private ListFactory() { } public AList makeEmptyList() { return EmptyList.Singleton; } /** * Creates a non-empty list with a given non-null first element and * a non-null rest. * Throws an IllegalArgumentException if any of the parameters is null. * * @param first != null, the first data element of the non-empty list. * @param rest != null, the rest of this non-empty list. */ public AList makeNEList(Object first, AList rest) { if (first == null || rest == null) { throw new IllegalArgumentException ("first and rest must be non-null."); } return new NEList (first, rest); } }