1 43 44 package org.jfree.data; 45 46 import java.io.Serializable ; 47 48 import org.jfree.util.ObjectUtilities; 49 import org.jfree.util.PublicCloneable; 50 51 54 public class KeyedObject implements Cloneable , PublicCloneable, Serializable { 55 56 57 private static final long serialVersionUID = 2677930479256885863L; 58 59 60 private Comparable key; 61 62 63 private Object object; 64 65 71 public KeyedObject(Comparable key, Object object) { 72 this.key = key; 73 this.object = object; 74 } 75 76 81 public Comparable getKey() { 82 return this.key; 83 } 84 85 90 public Object getObject() { 91 return this.object; 92 } 93 94 99 public void setObject(Object object) { 100 this.object = object; 101 } 102 103 113 public Object clone() throws CloneNotSupportedException { 114 KeyedObject clone = (KeyedObject) super.clone(); 115 if (this.object instanceof PublicCloneable) { 116 PublicCloneable pc = (PublicCloneable) this.object; 117 clone.object = pc.clone(); 118 } 119 return clone; 120 } 121 122 129 public boolean equals(Object obj) { 130 131 if (obj == this) { 132 return true; 133 } 134 135 if (!(obj instanceof KeyedObject)) { 136 return false; 137 } 138 KeyedObject that = (KeyedObject) obj; 139 if (!ObjectUtilities.equal(this.key, that.key)) { 140 return false; 141 } 142 143 if (!ObjectUtilities.equal(this.object, that.object)) { 144 return false; 145 } 146 147 return true; 148 } 149 150 } 151 | Popular Tags |