1 7 8 9 package javax.management.openmbean; 10 11 12 import java.io.Serializable ; 15 import java.util.Arrays ; 16 17 import javax.management.MBeanOperationInfo ; 20 import javax.management.MBeanParameterInfo ; 21 22 23 32 public class OpenMBeanOperationInfoSupport 33 extends MBeanOperationInfo 34 implements OpenMBeanOperationInfo , Serializable { 35 36 37 38 static final long serialVersionUID = 4996859732565369366L; 39 40 45 private OpenType returnOpenType; 46 47 48 private transient Integer myHashCode = null; private transient String myToString = null; 51 52 77 public OpenMBeanOperationInfoSupport(String name, 78 String description, 79 OpenMBeanParameterInfo [] signature, 80 OpenType returnOpenType, 81 int impact) { 82 83 super(name, 84 description, 85 ( signature == null ? null : arrayCopyCast(signature) ), ( returnOpenType == null ? null : returnOpenType.getClassName() ), 87 impact); 88 89 if ( (name == null) || (name.trim().equals("")) ) { 92 throw new IllegalArgumentException ("Argument name cannot be null or empty."); 93 } 94 if ( (description == null) || (description.trim().equals("")) ) { 95 throw new IllegalArgumentException ("Argument description cannot be null or empty."); 96 } 97 if (returnOpenType == null) { 98 throw new IllegalArgumentException ("Argument returnOpenType cannot be null."); 99 } 100 101 if ( (impact != super.ACTION) && (impact != super.ACTION_INFO) && (impact != super.INFO) ) { 104 throw new IllegalArgumentException ("Argument impact can be only one of ACTION, ACTION_INFO or INFO."); 105 } 106 107 this.returnOpenType = returnOpenType; 108 } 109 110 111 private static MBeanParameterInfo [] arrayCopyCast(OpenMBeanParameterInfo [] src) throws ArrayStoreException { 112 113 MBeanParameterInfo [] dst = new MBeanParameterInfo [src.length]; 114 System.arraycopy(src, 0, dst, 0, src.length); return dst; 116 } 117 118 119 122 123 126 public OpenType getReturnOpenType() { 127 128 return returnOpenType; 129 } 130 131 132 133 134 135 136 155 public boolean equals(Object obj) { 156 157 if (obj == null) { 160 return false; 161 } 162 163 OpenMBeanOperationInfo other; 166 try { 167 other = (OpenMBeanOperationInfo ) obj; 168 } catch (ClassCastException e) { 169 return false; 170 } 171 172 175 if ( ! this.getName().equals(other.getName()) ) { 177 return false; 178 } 179 180 if ( ! Arrays.equals(this.getSignature(), other.getSignature()) ) { 182 return false; 183 } 184 185 if ( ! this.getReturnOpenType().equals(other.getReturnOpenType()) ) { 187 return false; 188 } 189 190 if ( this.getImpact() != other.getImpact() ) { 192 return false; 193 } 194 195 return true; 198 } 199 200 222 public int hashCode() { 223 224 if (myHashCode == null) { 227 int value = 0; 228 value += this.getName().hashCode(); 229 value += Arrays.asList(this.getSignature()).hashCode(); 230 value += this.getReturnOpenType().hashCode(); 231 value += this.getImpact(); 232 myHashCode = new Integer (value); 233 } 234 235 return myHashCode.intValue(); 238 } 239 240 252 public String toString() { 253 254 if (myToString == null) { 257 myToString = new StringBuffer () 258 .append(this.getClass().getName()) 259 .append("(name=") 260 .append(this.getName()) 261 .append(",signature=") 262 .append(Arrays.asList(this.getSignature()).toString()) 263 .append(",return=") 264 .append(this.getReturnOpenType().toString()) 265 .append(",impact=") 266 .append(this.getImpact()) 267 .append(")") 268 .toString(); 269 } 270 271 return myToString; 274 } 275 276 } 277 | Popular Tags |