package javax.management;
import java.util.Arrays;
public class MBeanInfo
implements Cloneable, java.io.Serializable
{
private static final long serialVersionUID = -6451021435135161911L;
private String className = null;
private String description = null;
private MBeanAttributeInfo[] attributes = null;
private MBeanConstructorInfo[] constructors = null;
private MBeanOperationInfo[] operations = null;
private MBeanNotificationInfo[] notifications = null;
private transient String cacheString;
private transient int cacheHashCode;
public MBeanInfo(String className, String description,
MBeanAttributeInfo[] attributes,
MBeanConstructorInfo[] constructors,
MBeanOperationInfo[] operations,
MBeanNotificationInfo[] notifications) throws IllegalArgumentException
{
this.className = className;
this.description = description;
this.attributes = (null == attributes) ? new MBeanAttributeInfo[0] : (MBeanAttributeInfo[]) attributes.clone();
this.constructors = (null == constructors) ? new MBeanConstructorInfo[0] : (MBeanConstructorInfo[]) constructors.clone();
this.operations = (null == operations) ? new MBeanOperationInfo[0] : (MBeanOperationInfo[]) operations.clone();
this.notifications = (null == notifications) ? new MBeanNotificationInfo[0] : (MBeanNotificationInfo[]) notifications.clone();
}
public String getClassName()
{
return className;
}
public String getDescription()
{
return description;
}
public MBeanAttributeInfo[] getAttributes()
{
return (MBeanAttributeInfo[]) attributes.clone();
}
public MBeanOperationInfo[] getOperations()
{
return (MBeanOperationInfo[]) operations.clone();
}
public MBeanConstructorInfo[] getConstructors()
{
return (MBeanConstructorInfo[]) constructors.clone();
}
public MBeanNotificationInfo[] getNotifications()
{
return (MBeanNotificationInfo[]) notifications.clone();
}
public boolean equals(Object object)
{
if (this == object)
return true;
if (object == null || (object instanceof MBeanInfo) == false)
return false;
MBeanInfo other = (MBeanInfo) object;
if (this.getClassName().equals(other.getClassName()) == false)
return false;
if (this.getDescription().equals(other.getDescription()) == false)
return false;
MBeanAttributeInfo[] thisAttrs = this.getAttributes();
MBeanAttributeInfo[] otherAttrs = other.getAttributes();
if (thisAttrs.length != otherAttrs.length)
return false;
for (int i = 0; i < thisAttrs.length; ++i)
if (thisAttrs[i].equals(otherAttrs[i]) == false)
return false;
MBeanConstructorInfo[] thisCons = this.getConstructors();
MBeanConstructorInfo[] otherCons = other.getConstructors();
if (thisCons.length != otherCons.length)
return false;
for (int i = 0; i < thisCons.length; ++i)
if (thisCons[i].equals(otherCons[i]) == false)
return false;
MBeanNotificationInfo[] thisNotfs = this.getNotifications();
MBeanNotificationInfo[] otherNotfs = other.getNotifications();
if (thisNotfs.length != otherNotfs.length)
return false;
for (int i = 0; i < thisNotfs.length; ++i)
if (thisNotfs[i].equals(otherNotfs[i]) == false)
return false;
MBeanOperationInfo[] thisOpers = this.getOperations();
MBeanOperationInfo[] otherOpers = other.getOperations();
if (thisOpers.length != otherOpers.length)
return false;
for (int i = 0; i < thisOpers.length; ++i)
if (thisOpers[i].equals(otherOpers[i]) == false)
return false;
return true;
}
public int hashCode()
{
if (cacheHashCode == 0)
{
cacheHashCode = getClassName().hashCode();
cacheHashCode = getDescription().hashCode();
}
return cacheHashCode;
}
public String toString()
{
if (cacheString == null)
{
StringBuffer buffer = new StringBuffer(100);
buffer.append(getClass().getName()).append(":");
buffer.append(" className=").append(getClassName());
buffer.append(" description=").append(getDescription());
buffer.append(" attributes=").append(Arrays.asList(attributes));
buffer.append(" constructors=").append(Arrays.asList(constructors));
buffer.append(" notifications=").append(Arrays.asList(notifications));
buffer.append(" operations=").append(Arrays.asList(operations));
cacheString = buffer.toString();
}
return cacheString;
}
public Object clone()
{
MBeanInfo clone = null;
try
{
clone = (MBeanInfo) super.clone();
clone.className = getClassName();
clone.description = getDescription();
clone.attributes = getAttributes();
clone.constructors = getConstructors();
clone.operations = getOperations();
clone.notifications = getNotifications();
}
catch(CloneNotSupportedException e)
{
}
return clone;
}
}