1 package jfun.parsec.tokens; 2 9 public class TypedToken<Type> extends NamedToken { 10 private final Type type; 11 12 public TypedToken(String name, Type type) { 13 super(name); 14 this.type = type; 15 } 16 20 public final String getText(){ 21 return getName(); 22 } 23 26 public Type getType() { 27 return type; 28 } 29 public boolean equals(TypedToken other){ 30 return type.equals(other.type) && super.equals(other); 31 } 32 public boolean equals(Object obj) { 33 if(obj instanceof TypedToken){ 34 return equals((TypedToken)obj); 35 } 36 else return false; 37 } 38 39 public int hashCode() { 40 return type.hashCode() * 31 + super.hashCode(); 41 } 42 } 43 | Popular Tags |