import java.util.ArrayList;

/**
 * A <code>Definitions</code> object consists of a list of alternatives
 * (each of which is a list of terminals and/or nonterminals), but
 * does not include the thing being defined.
 */
public class Definitions extends ArrayList<SingleDefinition> {
    
    /**
     * Constructs an empty list of definitions.
     */
    Definitions() {}
    
    /**
     * Returns a string containing the contents of this <code>ArrayList</code>,
     * separated by <code>" | "</code> symbols.
     * 
     * @see java.util.AbstractCollection#toString()
     */
    @Override
    public String toString() {
        switch (size()) {
            case 0: return "";
            case 1: return get(0).toString();
            default: {
                String result = get(0).toString();
                for (int i = 1; i < size(); i++) {
                    result += " | " + get(i).toString();
                }
                return result;
            }
        }
    }
}
