1 8 14 package jfun.yan; 15 16 26 public final class PropertyEntry implements java.io.Serializable { 27 private final Object obj; 28 private final Object key; 29 30 35 public PropertyEntry(final Object obj, final Object key) { 36 this.obj = obj; 37 this.key = key; 38 } 39 40 44 public Object getPropertyKey() { 45 return key; 46 } 47 51 public Object getObject() { 52 return obj; 53 } 54 55 public boolean equals(Object o) { 56 if(o instanceof PropertyEntry){ 57 final PropertyEntry other = (PropertyEntry)o; 58 return eq(key, other.key) && eq(obj, other.obj); 59 } 60 else return false; 61 } 62 private static boolean eq(Object o1, Object o2){ 63 return o1==null?o2==null:o1.equals(o2); 64 } 65 private static int hcode(Object o){ 66 return o==null?0:o.hashCode(); 67 } 68 public int hashCode() { 69 return hcode(obj)*31+hcode(key); 70 } 71 public String toString() { 72 return "property " + key + " of <" + obj + ">"; 73 } 74 } 75 | Popular Tags |