01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: package javax.management;
10:
11: import java.io.Serializable;
12: import java.lang.reflect.Constructor;
13:
14: import mx4j.util.Utils;
15:
16: /**
17: * Metadata class for an MBean constructor
18: *
19: * @version $Revision: 1.13 $
20: */
21: // Change not needed, workaround to a TCK bug only to achieve TCK compliance
22: // public class MBeanConstructorInfo extends MBeanFeatureInfo implements Cloneable
23: public class MBeanConstructorInfo extends MBeanFeatureInfo implements
24: Cloneable, Serializable {
25: private static final long serialVersionUID = 4433990064191844427L;
26:
27: /**
28: * @serial The signature of the constructor
29: */
30: private MBeanParameterInfo[] signature;
31:
32: /**
33: * Creates a new MBeanConstructorInfo
34: *
35: * @param description The constructor description
36: * @param constructor The constructor
37: */
38: public MBeanConstructorInfo(String description,
39: Constructor constructor) {
40: super (constructor.getName(), description);
41: Class[] params = constructor.getParameterTypes();
42: this .signature = new MBeanParameterInfo[params.length];
43: for (int i = 0; i < params.length; ++i) {
44: this .signature[i] = new MBeanParameterInfo("", params[i]
45: .getName(), "");
46: }
47: }
48:
49: /**
50: * Creates a new MBeanConstructorInfo
51: *
52: * @param name The constructor's name, normally equals to the class name
53: * @param description The constructor description
54: * @param signature The constructor signature
55: */
56: public MBeanConstructorInfo(String name, String description,
57: MBeanParameterInfo[] signature) {
58: super (name, description);
59: this .signature = signature == null ? new MBeanParameterInfo[0]
60: : signature;
61: }
62:
63: public Object clone() {
64: try {
65: return super .clone();
66: } catch (CloneNotSupportedException ignored) {
67: return null;
68: }
69: }
70:
71: /**
72: * Returns the signature of this MBeanConstructorInfo
73: */
74: public MBeanParameterInfo[] getSignature() {
75: return signature;
76: }
77:
78: public int hashCode() {
79: return super .hashCode() + 29
80: * Utils.arrayHashCode(getSignature());
81: }
82:
83: public boolean equals(Object obj) {
84: if (!super .equals(obj))
85: return false;
86: if (!(obj instanceof MBeanConstructorInfo))
87: return false;
88:
89: MBeanConstructorInfo other = (MBeanConstructorInfo) obj;
90: return Utils.arrayEquals(getSignature(), other.getSignature());
91: }
92: }
|