package parser;

import java.io.Serializable;

/*
 * Created on 19 Sep 2010
 */

/**
 * @author Anthony Bryant
 * @param <T> - the enum type that holds all possible values for the token type
 */
public final class Production<T extends Enum<T>> implements Serializable
{
  private static final long serialVersionUID = 1L;

  private T[] types;

  /**
   * Creates a new Production with the specified types
   * @param types - the types that this production requires
   */
  public Production(T... types)
  {
    this.types = types;
  }

  /**
   * @return the types
   */
  public T[] getTypes()
  {
    return types;
  }

  /**
   * {@inheritDoc}
   * @see java.lang.Object#equals(java.lang.Object)
   */
  @Override
  public boolean equals(Object o)
  {
    if (!(o instanceof Production))
    {
      return false;
    }
    // this is not nice, but is necessary to check whether the productions
    // are equal without knowing their generic type parameters
    @SuppressWarnings("unchecked")
    Production<T> production = (Production<T>) o;
    if (types.length != production.types.length)
    {
      return false;
    }
    for (int i = 0; i < types.length; i++)
    {
      if (types[i] != production.types[i])
      {
        return false;
      }
    }
    return true;
  }
}

@@ -644,60 +644,8 @@
 oc%7D%0A
-   * @see java.lang.Object#equals(java.lang.Object)%0A
    *
@@ -1224,11 +1224,192 @@
 rue;%0A  %7D
+%0A%0A  @Override%0A  public int hashCode()%0A  %7B%0A    int hash = 0;%0A    for (int i = 0; i %3C types.length; i++)%0A    %7B%0A      hash = 31 * hash + types%5Bi%5D.hashCode();%0A    %7D%0A    return hash;%0A  %7D
 %0A%7D%0A

Add hashCode() to Production