1 16 package org.apache.commons.collections; 17 18 25 class LocalTestNode implements Comparable { 26 27 private Comparable key; 28 private Comparable value; 29 30 35 LocalTestNode(final int key) { 36 this.key = new Integer (key); 37 this.value = String.valueOf(key); 38 } 39 40 43 void setKey(Comparable key) { 44 this.key = key; 45 } 46 47 50 Comparable getKey() { 51 return key; 52 } 53 54 57 void setValue(Comparable value) { 58 this.value = value; 59 } 60 61 64 Comparable getValue() { 65 return value; 66 } 67 68 75 public int compareTo(Object o) { 76 77 LocalTestNode other = (LocalTestNode) o; 78 int rval = getKey().compareTo(other.getKey()); 79 80 if (rval == 0) { 81 rval = getValue().compareTo(other.getValue()); 82 } 83 84 return rval; 85 } 86 87 94 public boolean equals(Object o) { 95 96 if (o == null) { 97 return false; 98 } 99 100 if (!(o.getClass().equals(this.getClass()))) { 101 return false; 102 } 103 104 LocalTestNode node = (LocalTestNode) o; 105 106 return (getKey().equals(node.getKey()) 107 && getValue().equals(node.getValue())); 108 } 109 110 113 public int hashCode() { 114 return getKey().hashCode() ^ getValue().hashCode(); 115 } 116 } 117 | Popular Tags |