1 45 46 package org.jfree.data; 47 48 import java.io.Serializable ; 49 50 import org.jfree.util.PublicCloneable; 51 52 56 public class DefaultKeyedValue implements KeyedValue, 57 Cloneable , PublicCloneable, 58 Serializable { 59 60 61 private static final long serialVersionUID = -7388924517460437712L; 62 63 64 private Comparable key; 65 66 67 private Number value; 68 69 75 public DefaultKeyedValue(Comparable key, Number value) { 76 this.key = key; 77 this.value = value; 78 } 79 80 85 public Comparable getKey() { 86 return this.key; 87 } 88 89 94 public Number getValue() { 95 return this.value; 96 } 97 98 103 public synchronized void setValue(Number value) { 104 this.value = value; 105 } 106 107 114 public boolean equals(Object obj) { 115 if (obj == this) { 116 return true; 117 } 118 if (!(obj instanceof DefaultKeyedValue)) { 119 return false; 120 } 121 DefaultKeyedValue that = (DefaultKeyedValue) obj; 124 125 if (this.key != null ? !this.key.equals(that.key) : that.key != null) { 128 return false; 129 } 130 if (this.value != null 131 ? !this.value.equals(that.value) : that.value != null) { 132 return false; 133 } 134 return true; 135 } 136 137 142 public int hashCode() { 143 int result; 144 result = (this.key != null ? this.key.hashCode() : 0); 145 result = 29 * result + (this.value != null ? this.value.hashCode() : 0); 146 return result; 147 } 148 149 159 public Object clone() throws CloneNotSupportedException { 160 DefaultKeyedValue clone = (DefaultKeyedValue) super.clone(); 161 return clone; 162 } 163 164 } 165 | Popular Tags |