001: /*
002: * Copyright (C) The MX4J Contributors.
003: * All rights reserved.
004: *
005: * This software is distributed under the terms of the MX4J License version 1.0.
006: * See the terms of the MX4J License in the documentation provided with this software.
007: */
008:
009: package javax.management;
010:
011: import java.io.Serializable;
012:
013: import mx4j.util.Utils;
014:
015: /**
016: * @version $Revision: 1.15 $
017: */
018: public class MBeanInfo implements Cloneable, Serializable {
019: private static final long serialVersionUID = -6451021435135161911L;
020:
021: private static final MBeanConstructorInfo[] EMPTY_CONSTRUCTORS = new MBeanConstructorInfo[0];
022: private static final MBeanAttributeInfo[] EMPTY_ATTRIBUTES = new MBeanAttributeInfo[0];
023: private static final MBeanOperationInfo[] EMPTY_OPERATIONS = new MBeanOperationInfo[0];
024: private static final MBeanNotificationInfo[] EMPTY_NOTIFICATIONS = new MBeanNotificationInfo[0];
025:
026: /**
027: * @serial The MBean class name
028: */
029: private String className;
030: /**
031: * @serial The MBean description
032: */
033: private String description;
034: /**
035: * @serial The MBean constructors
036: */
037: private MBeanConstructorInfo[] constructors;
038: /**
039: * The MBean attributes
040: */
041: private MBeanAttributeInfo[] attributes;
042: /**
043: * The MBean operations
044: */
045: private MBeanOperationInfo[] operations;
046: /**
047: * The MBean notifications
048: */
049: private MBeanNotificationInfo[] notifications;
050:
051: public MBeanInfo(String className, String description,
052: MBeanAttributeInfo[] attributes,
053: MBeanConstructorInfo[] constructors,
054: MBeanOperationInfo[] operations,
055: MBeanNotificationInfo[] notifications) {
056: this .className = className;
057: this .description = description;
058: this .constructors = constructors == null
059: || constructors.length == 0 ? EMPTY_CONSTRUCTORS
060: : constructors;
061: this .attributes = attributes == null || attributes.length == 0 ? EMPTY_ATTRIBUTES
062: : attributes;
063: this .operations = operations == null || operations.length == 0 ? EMPTY_OPERATIONS
064: : operations;
065: this .notifications = notifications == null
066: || notifications.length == 0 ? EMPTY_NOTIFICATIONS
067: : notifications;
068: }
069:
070: public Object clone() {
071: // This class is read only, so no need to clone also data members
072: try {
073: return super .clone();
074: } catch (CloneNotSupportedException x) {
075: return null;
076: }
077: }
078:
079: public String getClassName() {
080: return className;
081: }
082:
083: public String getDescription() {
084: return description;
085: }
086:
087: public MBeanConstructorInfo[] getConstructors() {
088: return constructors;
089: }
090:
091: public MBeanAttributeInfo[] getAttributes() {
092: return attributes;
093: }
094:
095: public MBeanOperationInfo[] getOperations() {
096: return operations;
097: }
098:
099: public MBeanNotificationInfo[] getNotifications() {
100: return notifications;
101: }
102:
103: public int hashCode() {
104: int hash = 0;
105: String cn = getClassName();
106: if (cn != null)
107: hash = 29 * hash + cn.hashCode();
108: String de = getDescription();
109: if (de != null)
110: hash = 29 * hash + de.hashCode();
111: MBeanConstructorInfo[] co = getConstructors();
112: if (co != null)
113: hash = 29 * hash + Utils.arrayHashCode(co);
114: MBeanAttributeInfo[] at = getAttributes();
115: if (at != null)
116: hash = 29 * hash + Utils.arrayHashCode(at);
117: MBeanOperationInfo[] op = getOperations();
118: if (op != null)
119: hash = 29 * hash + Utils.arrayHashCode(op);
120: MBeanNotificationInfo[] no = getNotifications();
121: if (no != null)
122: hash = 29 * hash + Utils.arrayHashCode(no);
123: return hash;
124: }
125:
126: public boolean equals(Object obj) {
127: if (obj == this )
128: return true;
129: if (!(obj instanceof MBeanInfo))
130: return false;
131:
132: MBeanInfo other = (MBeanInfo) obj;
133: String this ClassName = getClassName();
134: String otherClassName = other.getClassName();
135: if (this ClassName != null ? !this ClassName
136: .equals(otherClassName) : otherClassName != null)
137: return false;
138: String this Description = getDescription();
139: String otherDescription = other.getDescription();
140: if (this Description != null ? !this Description
141: .equals(otherDescription) : otherDescription != null)
142: return false;
143: if (!Utils.arrayEquals(getConstructors(), other
144: .getConstructors()))
145: return false;
146: if (!Utils.arrayEquals(getAttributes(), other.getAttributes()))
147: return false;
148: if (!Utils.arrayEquals(getOperations(), other.getOperations()))
149: return false;
150: if (!Utils.arrayEquals(getNotifications(), other
151: .getNotifications()))
152: return false;
153: return true;
154: }
155: }
|