1 4 package gnu.mapping; 5 6 7 8 public class KeyPair implements EnvironmentKey 9 { 10 Symbol name; 11 Object property; 12 13 public KeyPair (Symbol name, Object property) 14 { 15 this.name = name; 16 this.property = property; 17 } 18 19 public Symbol getKeySymbol () { return name; } 20 public Object getKeyProperty () { return property; } 21 22 public final boolean matches (EnvironmentKey key) 23 { 24 return Symbol.equals(key.getKeySymbol(), this.name) 25 && key.getKeyProperty() == this.property; 26 } 27 28 public final boolean matches (Symbol symbol, Object property) 29 { 30 return Symbol.equals(symbol, this.name) && property == this.property; 31 } 32 33 public boolean equals (Object x) 34 { 35 if (! (x instanceof KeyPair)) 36 return false; 37 KeyPair e2 = (KeyPair) x; 38 return property == e2.property 39 && (name == null ? e2.name == null : name.equals(e2.name)); 40 } 41 42 public int hashCode () 43 { 44 return name.hashCode() ^ System.identityHashCode(property); 45 } 46 47 public String toString () { return "KeyPair[sym:"+name+" prop:"+property+"]"; } 48 } 49 | Popular Tags |