/* This file is part of SableCC (http://sablecc.org/).
 * 
 * See the NOTICE file distributed with this work for copyright information.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.sablecc.sablecc.alphabet;

class SymbolPair<T extends Comparable<? super T>> {

    private final Symbol<T> symbol1;

    private final Symbol<T> symbol2;

    private Integer hashCode;

    SymbolPair(
            Symbol<T> symbol1,
            Symbol<T> symbol2) {

        this.symbol1 = symbol1;
        this.symbol2 = symbol2;
    }

    public Symbol<T> getSymbol1() {

        return this.symbol1;
    }

    public Symbol<T> getSymbol2() {

        return this.symbol2;
    }

    @Override
    public boolean equals(
            Object obj) {

        if (obj == null) {
            return false;
        }

        if (!(obj instanceof SymbolPair)) {
            return false;
        }

        SymbolPair symbolPair = (SymbolPair) obj;

        if (this.symbol1 == null && symbolPair.symbol1 != null) {
            return false;
        }

        if (this.symbol2 == null && symbolPair.symbol2 != null) {
            return false;
        }

        return (this.symbol1 == null || this.symbol1.equals(symbolPair.symbol1))
                && (this.symbol2 == null || this.symbol2
                        .equals(symbolPair.symbol2));
    }

    @Override
    public int hashCode() {

        if (this.hashCode == null) {

            int hashCode = 0;

            if (this.symbol1 != null) {
                hashCode += this.symbol1.hashCode();
            }

            if (this.symbol2 != null) {
                hashCode += 17 * this.symbol2.hashCode();
            }

            this.hashCode = hashCode;
        }

        return this.hashCode;
    }
}

@@ -735,465 +735,1613 @@
 t;%0A%0A
-class SymbolPair%3CT extends Comparable%3C? super T%3E%3E %7B%0A%0A    private final Symbol%3CT%3E symbol1;%0A%0A    private final Symbol%3CT%3E symbol2;%0A%0A    private Integer hashCode;%0A%0A    SymbolPair(%0A            Symbol%3CT%3E symbol1,%0A            Symbol%3CT%3E symbol2) %7B%0A%0A        this.symbol1 = symbol1;%0A        this.symbol2 = symbol2;%0A    %7D%0A%0A    public Symbol%3CT%3E getSymbol1() %7B%0A%0A        return this.symbol1;%0A    %7D%0A%0A    public Symbol%3CT%3E getSymbol2() %7B%0A%0A        return this.symbol2;%0A    %7D%0A
+/**%0A * This class represents a pair of symbols.%0A * %0A * A symbol pair is defined by two distinct symbols.%0A */%0Aclass SymbolPair%3CT extends Comparable%3C? super T%3E%3E %7B%0A%0A    /** The first unmodifiable symbol of the pair */%0A    private final Symbol%3CT%3E symbol1;%0A%0A    /** The second unmodifiable symbol of the pair */%0A    private final Symbol%3CT%3E symbol2;%0A%0A    /** Cached hashcode. Is %3Ccode%3Enull%3C/code%3E when not yet computed. */%0A    private Integer hashCode;%0A%0A    /**%0A     * Constructs a symbol pair with two provided symbols.%0A     * %0A     * @param symbol1%0A     *            the first symbol of the pair.%0A     * @param symbol2%0A     *            the second symbol of the pair.%0A     */%0A    SymbolPair(%0A            Symbol%3CT%3E symbol1,%0A            Symbol%3CT%3E symbol2) %7B%0A%0A        this.symbol1 = symbol1;%0A        this.symbol2 = symbol2;%0A    %7D%0A%0A    /**%0A     * Returns the first symbol of the pair.%0A     * %0A     * @return the first symbol of the pair.%0A     */%0A    public Symbol%3CT%3E getSymbol1() %7B%0A%0A        return this.symbol1;%0A    %7D%0A%0A    /**%0A     * Returns the second symbol of the pair.%0A     * %0A     * @return the second symbol of the pair.%0A     */%0A    public Symbol%3CT%3E getSymbol2() %7B%0A%0A        return this.symbol2;%0A    %7D%0A%0A    /**%0A     * Compares this symbol pair with an object for equality. Returns%0A     * %3Ccode%3Etrue%3C/code%3E if the object is a symbol pair and if it as the same%0A     * two symbols as those of this instance.%0A     * %0A     * @param obj%0A     *            the object to compare with.%0A     * @return %3Ccode%3Etrue%3C/code%3E if this symbol pair and the object are equal;%0A     *         %3Ccode%3Efalse%3C/code%3E otherwise.%0A     */
 %0A   
@@ -3002,24 +3002,142 @@
 2));%0A    %7D%0A%0A
+    /**%0A     * Returns a hash code value for this object.%0A     * %0A     * @return a hash code for this object.%0A     */%0A
     @Overrid

Add javadoc comments.