package list; /** * Manufactures AList objects. * Implemented as a singleton. * * @author Dung X. Nguyen * @version 1.0 * @since 09/10/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 of the list. * Throws an IllegalArgumentException if any of the parameters is null. * * @param first != null, the first 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 ("makeNEList: first and rest must be non-null."); } return new NEList (first, rest); } }