/* 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.structure;

import org.sablecc.sablecc.exception.InternalException;

public class State
        implements Comparable<State> {

    private final String name;

    State(
            String name) {

        this.name = name;
    }

    public boolean hasName() {

        return this.name != null;
    }

    public String getName() {

        if (this.name == null) {
            throw new InternalException("this state does not have a name");
        }

        return this.name;
    }

    @Override
    public boolean equals(
            Object obj) {

        if (this == obj) {
            return true;
        }

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

        if (getClass() != obj.getClass()) {
            return false;
        }

        State state = (State) obj;

        if (this.name == null) {
            return this.name == state.name;
        }

        return this.name.equals(state.name);
    }

    @Override
    public int hashCode() {

        if (this.name == null) {
            return 0;
        }

        return this.name.hashCode();
    }

    public int compareTo(
            State state) {

        if (this.name == null) {
            if (state.name == null) {
                return 0;
            }

            return -1;
        }
        else if (state == null) {
            return 1;
        }

        return this.name.compareTo(state.name);
    }
}

@@ -793,427 +793,1403 @@
 n;%0A%0A
-public class State%0A        implements Comparable%3CState%3E %7B%0A%0A    private final String name;%0A%0A    State(%0A            String name) %7B%0A%0A        this.name = name;%0A    %7D%0A%0A    public boolean hasName() %7B%0A%0A        return this.name != null;%0A    %7D%0A%0A    public String getName() %7B%0A%0A        if (this.name == null) %7B%0A            throw new InternalException(%22this state does not have a name%22);%0A        %7D%0A%0A        return this.name;%0A    %7D%0A
+/**%0A * A state is defined by its name. Each state correspond to a state defined in%0A * the grammar specification.%0A */%0Apublic class State%0A        implements Comparable%3CState%3E %7B%0A%0A    /** The name of this state. */%0A    private final String name;%0A%0A    /**%0A     * Constructs a state with the provided name.%0A     * %0A     * @param name%0A     *            the name.%0A     */%0A    State(%0A            String name) %7B%0A%0A        this.name = name;%0A    %7D%0A%0A    /**%0A     * Returns whether this state has a name or not.%0A     * %0A     * @return %3Ccode%3Etrue%3C/code%3E if this state has a name, %3Ccode%3Efalse%3C/code%3E%0A     *         otherwise.%0A     */%0A    public boolean hasName() %7B%0A%0A        return this.name != null;%0A    %7D%0A%0A    /**%0A     * Returns the name of this state.%0A     * %0A     * @return the name.%0A     * @throws InternalException%0A     *             if this state has no name.%0A     */%0A    public String getName() %7B%0A%0A        if (this.name == null) %7B%0A            throw new InternalException(%22this state does not have a name%22);%0A        %7D%0A%0A        return this.name;%0A    %7D%0A%0A    /**%0A     * Returns whether this instance is equal to the provided object. They are%0A     * equal if they are the same object or if they have equal names.%0A     * %0A     * @param obj%0A     *            the object to compare with.%0A     * @return %3Ccode%3Etrue%3C/code%3E if this state and the object are equal;%0A     *         %3Ccode%3Efalse%3C/code%3E otherwise.%0A     */
 %0A   
@@ -2633,24 +2633,122 @@
 me);%0A    %7D%0A%0A
+    /**%0A     * Returns the hash code of this state.%0A     * %0A     * @return the hash code.%0A     */%0A
     @Overrid
@@ -2884,24 +2884,419 @@
 e();%0A    %7D%0A%0A
+    /**%0A     * Compares this state to the provided one. The comparison is made by%0A     * comparing their names.%0A     * %0A     * @param state%0A     *            the state to compare with.%0A     * @return an %3Ccode%3Eint%3C/code%3E value: %3Ccode%3E0%3C/code%3E if the two states%0A     *         are the equals, a negative value if this state is smaller, and a%0A     *         positive value if it is bigger.%0A     */%0A
     public i

Add javadoc comments. See ticket:78.