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: */package javax.management.openmbean;
08:
09: import java.io.Serializable;
10: import java.util.Arrays;
11: import javax.management.MBeanConstructorInfo;
12: import javax.management.MBeanParameterInfo;
13:
14: /**
15: * @version $Revision: 1.6 $
16: */
17: public class OpenMBeanConstructorInfoSupport extends
18: MBeanConstructorInfo implements OpenMBeanConstructorInfo,
19: Serializable {
20: private static final long serialVersionUID = -4400441579007477003L;
21:
22: // No non-transient fields allowed
23: private transient int m_hashcode = 0;
24:
25: public OpenMBeanConstructorInfoSupport(String name,
26: String description, OpenMBeanParameterInfo[] signature) {
27: super (name, description, signature == null ? null
28: : (MBeanParameterInfo[]) Arrays.asList(signature)
29: .toArray(new MBeanParameterInfo[0]));
30: if (name == null || name.trim().length() == 0)
31: throw new IllegalArgumentException(
32: "name parameter cannot be null or an empty string");
33: if (description == null || description.trim().length() == 0)
34: throw new IllegalArgumentException(
35: "description parameter cannot be null or an empty string");
36: }
37:
38: public boolean equals(Object obj) {
39: if (!(obj instanceof OpenMBeanConstructorInfo))
40: return false;
41: OpenMBeanConstructorInfo toCompare = (OpenMBeanConstructorInfo) obj;
42: return (getName().equals(toCompare.getName()) && Arrays.equals(
43: getSignature(), toCompare.getSignature()));
44: }
45:
46: public int hashCode() {
47: if (m_hashcode == 0) {
48: int result = getName().hashCode();
49: result += Arrays.asList(getSignature()).hashCode();
50: m_hashcode = result;
51: }
52: return m_hashcode;
53: }
54:
55: public String toString() {
56: return (getClass().getName() + " ( name = " + getName()
57: + " signature = "
58: + Arrays.asList(getSignature()).toString() + " )");
59: }
60: }
|