1 7 8 package javax.management; 9 10 import java.io.Serializable ; 12 13 import javax.management.ObjectName ; 15 16 17 24 public class ObjectInstance implements Serializable { 25 26 27 28 private static final long serialVersionUID = -4099952623687795850L; 29 30 33 private ObjectName name; 34 35 38 private String className; 39 40 55 public ObjectInstance(String objectName, String className) 56 throws MalformedObjectNameException { 57 this(new ObjectName (objectName), className); 58 } 59 60 74 public ObjectInstance(ObjectName objectName, String className) { 75 if (objectName.isPattern()) { 76 final IllegalArgumentException iae = 77 new IllegalArgumentException ("Invalid name->"+ 78 objectName.toString()); 79 throw new RuntimeOperationsException (iae); 80 } 81 this.name= objectName; 82 this.className= className; 83 } 84 85 86 94 public boolean equals(Object object) { 95 if (!(object instanceof ObjectInstance )) { 96 return false; 97 } 98 ObjectInstance val = (ObjectInstance ) object; 99 if (! name.equals(val.getObjectName())) return false; 100 if (className == null) 101 return (val.getClassName() == null); 102 return className.equals(val.getClassName()); 103 } 104 105 public int hashCode() { 106 final int classHash = ((className==null)?0:className.hashCode()); 107 return name.hashCode() ^ classHash; 108 } 109 110 115 public ObjectName getObjectName() { 116 return name; 117 } 118 119 124 public String getClassName() { 125 return className; 126 } 127 128 } 129 | Popular Tags |