1 7 8 package javax.management; 9 10 import java.util.Arrays ; 11 12 39 public class MBeanNotificationInfo extends MBeanFeatureInfo implements Cloneable , java.io.Serializable { 40 41 42 static final long serialVersionUID = -3888371564530107064L; 43 44 private static final String [] NO_TYPES = new String [0]; 45 46 static final MBeanNotificationInfo [] NO_NOTIFICATIONS = 47 new MBeanNotificationInfo [0]; 48 49 52 private final String [] types; 53 54 55 private final transient boolean immutable; 56 57 67 public MBeanNotificationInfo(String [] notifTypes, 68 String name, 69 String description) 70 throws IllegalArgumentException { 71 super(name, description); 72 73 74 79 80 if (notifTypes == null) 81 notifTypes = NO_TYPES; 82 this.types = notifTypes; 83 this.immutable = 84 MBeanInfo.isImmutableClass(this.getClass(), 85 MBeanNotificationInfo .class); 86 } 87 88 89 96 public Object clone () { 97 try { 98 return super.clone() ; 99 } catch (CloneNotSupportedException e) { 100 return null; 102 } 103 } 104 105 106 113 public String [] getNotifTypes() { 114 if (types.length == 0) 115 return NO_TYPES; 116 else 117 return (String []) types.clone(); 118 } 119 120 private String [] fastGetNotifTypes() { 121 if (immutable) 122 return types; 123 else 124 return getNotifTypes(); 125 } 126 127 140 public boolean equals(Object o) { 141 if (o == this) 142 return true; 143 if (!(o instanceof MBeanNotificationInfo )) 144 return false; 145 MBeanNotificationInfo p = (MBeanNotificationInfo ) o; 146 return (p.getName().equals(getName()) && 147 p.getDescription().equals(getDescription()) && 148 Arrays.equals(p.fastGetNotifTypes(), fastGetNotifTypes())); 149 } 150 151 public int hashCode() { 152 int hash = getName().hashCode(); 153 for (int i = 0; i < types.length; i++) 154 hash ^= types[i].hashCode(); 155 return hash; 156 } 157 } 158 | Popular Tags |