1 7 8 9 package javax.management.openmbean; 10 11 12 import java.io.Serializable ; 15 import java.util.Arrays ; 16 17 18 import javax.management.MBeanConstructorInfo ; 21 import javax.management.MBeanParameterInfo ; 22 23 24 33 public class OpenMBeanConstructorInfoSupport 34 extends MBeanConstructorInfo 35 implements OpenMBeanConstructorInfo , Serializable { 36 37 38 static final long serialVersionUID = -4400441579007477003L; 39 40 41 private transient Integer myHashCode = null; private transient String myToString = null; 44 61 public OpenMBeanConstructorInfoSupport(String name, 62 String description, 63 OpenMBeanParameterInfo [] signature) { 64 65 super(name, 66 description, 67 ( signature == null ? null : arrayCopyCast(signature) )); 69 if ( (name == null) || (name.trim().equals("")) ) { 72 throw new IllegalArgumentException ("Argument name cannot be null or empty."); 73 } 74 if ( (description == null) || (description.trim().equals("")) ) { 75 throw new IllegalArgumentException ("Argument description cannot be null or empty."); 76 } 77 78 } 79 80 private static MBeanParameterInfo [] arrayCopyCast(OpenMBeanParameterInfo [] src) throws ArrayStoreException { 81 82 MBeanParameterInfo [] dst = new MBeanParameterInfo [src.length]; 83 System.arraycopy(src, 0, dst, 0, src.length); return dst; 85 } 86 87 88 89 90 91 108 public boolean equals(Object obj) { 109 110 if (obj == null) { 113 return false; 114 } 115 116 OpenMBeanConstructorInfo other; 119 try { 120 other = (OpenMBeanConstructorInfo ) obj; 121 } catch (ClassCastException e) { 122 return false; 123 } 124 125 128 if ( ! this.getName().equals(other.getName()) ) { 130 return false; 131 } 132 133 if ( ! Arrays.equals(this.getSignature(), other.getSignature()) ) { 135 return false; 136 } 137 138 return true; 141 } 142 143 165 public int hashCode() { 166 167 if (myHashCode == null) { 170 int value = 0; 171 value += this.getName().hashCode(); 172 value += Arrays.asList(this.getSignature()).hashCode(); 173 myHashCode = new Integer (value); 174 } 175 176 return myHashCode.intValue(); 179 } 180 181 193 public String toString() { 194 195 if (myToString == null) { 198 myToString = new StringBuffer () 199 .append(this.getClass().getName()) 200 .append("(name=") 201 .append(this.getName()) 202 .append(",signature=") 203 .append(Arrays.asList(this.getSignature()).toString()) 204 .append(")") 205 .toString(); 206 } 207 208 return myToString; 211 } 212 213 } 214 | Popular Tags |