package javax.management;
import java.util.Arrays;
public class MBeanNotificationInfo extends MBeanFeatureInfo
implements Cloneable, java.io.Serializable
{
private static final long serialVersionUID = -3888371564530107064L;
private String[] types = null;
private transient String cacheString;
private transient int cacheHashCode;
public MBeanNotificationInfo(String[] notifsType, String name, String description)
throws IllegalArgumentException
{
super(name, description);
this.types = (null == notifsType) ? new String[0] : (String[]) notifsType.clone();
}
public String[] getNotifTypes()
{
return (String[]) types.clone();
}
public boolean equals(Object object)
{
if (this == object)
return true;
if (object == null || (object instanceof MBeanNotificationInfo) == false)
return false;
MBeanNotificationInfo other = (MBeanNotificationInfo) object;
if (super.equals(other) == false)
return false;
String[] thisTypes = this.getNotifTypes();
String[] otherTypes = other.getNotifTypes();
if (thisTypes.length != otherTypes.length)
return false;
for (int i = 0; i < thisTypes.length; ++i)
if (thisTypes[i].equals(otherTypes[i]) == false)
return false;
return true;
}
public int hashCode()
{
if (cacheHashCode == 0)
{
cacheHashCode = super.hashCode();
}
return cacheHashCode;
}
public String toString()
{
if (cacheString == null)
{
StringBuffer buffer = new StringBuffer(100);
buffer.append(getClass().getName()).append(":");
buffer.append(" name=").append(getName());
buffer.append(" description=").append(getDescription());
buffer.append(" types=").append(Arrays.asList(types));
cacheString = buffer.toString();
}
return cacheString;
}
public Object clone()
{
MBeanNotificationInfo clone = null;
try
{
clone = (MBeanNotificationInfo) super.clone();
clone.types = getNotifTypes();
}
catch(CloneNotSupportedException e)
{
}
return clone;
}
}