1 10 package org.jgap.audit; 11 12 import java.io.Serializable ; 13 import org.jgap.util.*; 14 15 21 public class KeyedValue 22 implements ICloneable, Serializable { 23 24 private static final String CVS_REVISION = "$Revision: 1.3 $"; 25 26 private Comparable m_key; 27 28 private Number m_value; 29 30 39 public KeyedValue(final Comparable a_key, final Number a_value) { 40 m_key = a_key; 41 m_value = a_value; 42 } 43 44 50 public Comparable getKey() { 51 return m_key; 52 } 53 54 60 public synchronized Number getValue() { 61 return m_value; 62 } 63 64 72 public synchronized void setValue(final Number a_value) { 73 m_value = a_value; 74 } 75 76 86 public boolean equals(final Object a_object) { 87 if (this == a_object) { 88 return true; 89 } 90 if (! (a_object instanceof KeyedValue)) { 91 return false; 92 } 93 final KeyedValue defaultKeyedValue = (KeyedValue) a_object; 94 if (m_key != null ? !m_key.equals(defaultKeyedValue.m_key) 95 : defaultKeyedValue.m_key != null) { 96 return false; 97 } 98 if (m_value != null ? !m_value.equals(defaultKeyedValue.m_value) 99 : defaultKeyedValue.m_value != null) { 100 return false; 101 } 102 return true; 103 } 104 105 111 public int hashCode() { 112 int result; 113 if (m_key == null) { 114 result = -37; 115 } 116 else { 117 result = m_key.hashCode(); 118 } 119 result = 41 * result; 120 if (m_value == null) { 121 result += -3; 122 } 123 else { 124 result += m_value.hashCode(); 125 } 126 return result; 127 } 128 129 135 public Object clone() { 136 try { 137 KeyedValue clone = (KeyedValue)super.clone(); 138 return clone; 139 } catch (CloneNotSupportedException cex) { 140 throw new CloneException(cex); 141 } 142 } 143 } 144 | Popular Tags |