< prev index next >

src/java.management/share/classes/javax/management/MBeanAttributeInfo.java

Print this page




  75      */
  76     private final String attributeType;
  77 
  78     /**
  79      * @serial The attribute write right.
  80      */
  81     private final boolean isWrite;
  82 
  83     /**
  84      * @serial The attribute read right.
  85      */
  86     private final boolean isRead;
  87 
  88     /**
  89      * @serial Indicates if this method is a "is"
  90      */
  91     private final boolean is;
  92 
  93 
  94     /**
  95      * Constructs an <CODE>MBeanAttributeInfo</CODE> object.
  96      *
  97      * @param name The name of the attribute.
  98      * @param type The type or class name of the attribute.
  99      * @param description A human readable description of the attribute.
 100      * @param isReadable True if the attribute has a getter method, false otherwise.
 101      * @param isWritable True if the attribute has a setter method, false otherwise.
 102      * @param isIs True if this attribute has an "is" getter, false otherwise.
 103      *
 104      * @throws IllegalArgumentException if {@code isIs} is true but
 105      * {@code isReadable} is not, or if {@code isIs} is true and
 106      * {@code type} is not {@code boolean} or {@code java.lang.Boolean}.
 107      * (New code should always use {@code boolean} rather than
 108      * {@code java.lang.Boolean}.)
 109      */
 110     public MBeanAttributeInfo(String name,
 111                               String type,
 112                               String description,
 113                               boolean isReadable,
 114                               boolean isWritable,
 115                               boolean isIs) {
 116         this(name, type, description, isReadable, isWritable, isIs,
 117              (Descriptor) null);
 118     }
 119 
 120     /**
 121      * Constructs an <CODE>MBeanAttributeInfo</CODE> object.
 122      *
 123      * @param name The name of the attribute.
 124      * @param type The type or class name of the attribute.
 125      * @param description A human readable description of the attribute.
 126      * @param isReadable True if the attribute has a getter method, false otherwise.
 127      * @param isWritable True if the attribute has a setter method, false otherwise.
 128      * @param isIs True if this attribute has an "is" getter, false otherwise.
 129      * @param descriptor The descriptor for the attribute.  This may be null
 130      * which is equivalent to an empty descriptor.
 131      *
 132      * @throws IllegalArgumentException if {@code isIs} is true but
 133      * {@code isReadable} is not, or if {@code isIs} is true and
 134      * {@code type} is not {@code boolean} or {@code java.lang.Boolean}.
 135      * (New code should always use {@code boolean} rather than
 136      * {@code java.lang.Boolean}.)
 137      *
 138      * @since 1.6
 139      */
 140     public MBeanAttributeInfo(String name,
 141                               String type,


 176      *          May be null if the attribute is read-only.
 177      * @exception IntrospectionException There is a consistency
 178      * problem in the definition of this attribute.
 179      */
 180     public MBeanAttributeInfo(String name,
 181                               String description,
 182                               Method getter,
 183                               Method setter) throws IntrospectionException {
 184         this(name,
 185              attributeType(getter, setter),
 186              description,
 187              (getter != null),
 188              (setter != null),
 189              isIs(getter),
 190              ImmutableDescriptor.union(Introspector.descriptorForElement(getter),
 191                                    Introspector.descriptorForElement(setter)));
 192     }
 193 
 194     /**
 195      * <p>Returns a shallow clone of this instance.
 196      * The clone is obtained by simply calling <tt>super.clone()</tt>,
 197      * thus calling the default native shallow cloning mechanism
 198      * implemented by <tt>Object.clone()</tt>.
 199      * No deeper cloning of any internal field is made.</p>
 200      *
 201      * <p>Since this class is immutable, cloning is chiefly of
 202      * interest to subclasses.</p>
 203      */
 204      public Object clone () {
 205          try {
 206              return super.clone() ;
 207          } catch (CloneNotSupportedException e) {
 208              // should not happen as this class is cloneable
 209              return null;
 210          }
 211      }
 212 
 213     /**
 214      * Returns the class name of the attribute.
 215      *
 216      * @return the class name.
 217      */
 218     public String getType() {


 257             access = "write-only";
 258         else
 259             access = "no-access";
 260 
 261         return
 262             getClass().getName() + "[" +
 263             "description=" + getDescription() + ", " +
 264             "name=" + getName() + ", " +
 265             "type=" + getType() + ", " +
 266             access + ", " +
 267             (isIs() ? "isIs, " : "") +
 268             "descriptor=" + getDescriptor() +
 269             "]";
 270     }
 271 
 272     /**
 273      * Compare this MBeanAttributeInfo to another.
 274      *
 275      * @param o the object to compare to.
 276      *
 277      * @return true if and only if <code>o</code> is an MBeanAttributeInfo such
 278      * that its {@link #getName()}, {@link #getType()}, {@link
 279      * #getDescription()}, {@link #isReadable()}, {@link
 280      * #isWritable()}, and {@link #isIs()} values are equal (not
 281      * necessarily identical) to those of this MBeanAttributeInfo.
 282      */
 283     public boolean equals(Object o) {
 284         if (o == this)
 285             return true;
 286         if (!(o instanceof MBeanAttributeInfo))
 287             return false;
 288         MBeanAttributeInfo p = (MBeanAttributeInfo) o;
 289         return (Objects.equals(p.getName(), getName()) &&
 290                 Objects.equals(p.getType(), getType()) &&
 291                 Objects.equals(p.getDescription(), getDescription()) &&
 292                 Objects.equals(p.getDescriptor(), getDescriptor()) &&
 293                 p.isReadable() == isReadable() &&
 294                 p.isWritable() == isWritable() &&
 295                 p.isIs() == isIs());
 296     }
 297 




  75      */
  76     private final String attributeType;
  77 
  78     /**
  79      * @serial The attribute write right.
  80      */
  81     private final boolean isWrite;
  82 
  83     /**
  84      * @serial The attribute read right.
  85      */
  86     private final boolean isRead;
  87 
  88     /**
  89      * @serial Indicates if this method is a "is"
  90      */
  91     private final boolean is;
  92 
  93 
  94     /**
  95      * Constructs an {@code MBeanAttributeInfo} object.
  96      *
  97      * @param name The name of the attribute.
  98      * @param type The type or class name of the attribute.
  99      * @param description A human readable description of the attribute.
 100      * @param isReadable True if the attribute has a getter method, false otherwise.
 101      * @param isWritable True if the attribute has a setter method, false otherwise.
 102      * @param isIs True if this attribute has an "is" getter, false otherwise.
 103      *
 104      * @throws IllegalArgumentException if {@code isIs} is true but
 105      * {@code isReadable} is not, or if {@code isIs} is true and
 106      * {@code type} is not {@code boolean} or {@code java.lang.Boolean}.
 107      * (New code should always use {@code boolean} rather than
 108      * {@code java.lang.Boolean}.)
 109      */
 110     public MBeanAttributeInfo(String name,
 111                               String type,
 112                               String description,
 113                               boolean isReadable,
 114                               boolean isWritable,
 115                               boolean isIs) {
 116         this(name, type, description, isReadable, isWritable, isIs,
 117              (Descriptor) null);
 118     }
 119 
 120     /**
 121      * Constructs an {@code MBeanAttributeInfo} object.
 122      *
 123      * @param name The name of the attribute.
 124      * @param type The type or class name of the attribute.
 125      * @param description A human readable description of the attribute.
 126      * @param isReadable True if the attribute has a getter method, false otherwise.
 127      * @param isWritable True if the attribute has a setter method, false otherwise.
 128      * @param isIs True if this attribute has an "is" getter, false otherwise.
 129      * @param descriptor The descriptor for the attribute.  This may be null
 130      * which is equivalent to an empty descriptor.
 131      *
 132      * @throws IllegalArgumentException if {@code isIs} is true but
 133      * {@code isReadable} is not, or if {@code isIs} is true and
 134      * {@code type} is not {@code boolean} or {@code java.lang.Boolean}.
 135      * (New code should always use {@code boolean} rather than
 136      * {@code java.lang.Boolean}.)
 137      *
 138      * @since 1.6
 139      */
 140     public MBeanAttributeInfo(String name,
 141                               String type,


 176      *          May be null if the attribute is read-only.
 177      * @exception IntrospectionException There is a consistency
 178      * problem in the definition of this attribute.
 179      */
 180     public MBeanAttributeInfo(String name,
 181                               String description,
 182                               Method getter,
 183                               Method setter) throws IntrospectionException {
 184         this(name,
 185              attributeType(getter, setter),
 186              description,
 187              (getter != null),
 188              (setter != null),
 189              isIs(getter),
 190              ImmutableDescriptor.union(Introspector.descriptorForElement(getter),
 191                                    Introspector.descriptorForElement(setter)));
 192     }
 193 
 194     /**
 195      * <p>Returns a shallow clone of this instance.
 196      * The clone is obtained by simply calling {@code super.clone()},
 197      * thus calling the default native shallow cloning mechanism
 198      * implemented by {@code Object.clone()}.
 199      * No deeper cloning of any internal field is made.</p>
 200      *
 201      * <p>Since this class is immutable, cloning is chiefly of
 202      * interest to subclasses.</p>
 203      */
 204      public Object clone () {
 205          try {
 206              return super.clone() ;
 207          } catch (CloneNotSupportedException e) {
 208              // should not happen as this class is cloneable
 209              return null;
 210          }
 211      }
 212 
 213     /**
 214      * Returns the class name of the attribute.
 215      *
 216      * @return the class name.
 217      */
 218     public String getType() {


 257             access = "write-only";
 258         else
 259             access = "no-access";
 260 
 261         return
 262             getClass().getName() + "[" +
 263             "description=" + getDescription() + ", " +
 264             "name=" + getName() + ", " +
 265             "type=" + getType() + ", " +
 266             access + ", " +
 267             (isIs() ? "isIs, " : "") +
 268             "descriptor=" + getDescriptor() +
 269             "]";
 270     }
 271 
 272     /**
 273      * Compare this MBeanAttributeInfo to another.
 274      *
 275      * @param o the object to compare to.
 276      *
 277      * @return true if and only if {@code o} is an MBeanAttributeInfo such
 278      * that its {@link #getName()}, {@link #getType()}, {@link
 279      * #getDescription()}, {@link #isReadable()}, {@link
 280      * #isWritable()}, and {@link #isIs()} values are equal (not
 281      * necessarily identical) to those of this MBeanAttributeInfo.
 282      */
 283     public boolean equals(Object o) {
 284         if (o == this)
 285             return true;
 286         if (!(o instanceof MBeanAttributeInfo))
 287             return false;
 288         MBeanAttributeInfo p = (MBeanAttributeInfo) o;
 289         return (Objects.equals(p.getName(), getName()) &&
 290                 Objects.equals(p.getType(), getType()) &&
 291                 Objects.equals(p.getDescription(), getDescription()) &&
 292                 Objects.equals(p.getDescriptor(), getDescriptor()) &&
 293                 p.isReadable() == isReadable() &&
 294                 p.isWritable() == isWritable() &&
 295                 p.isIs() == isIs());
 296     }
 297 


< prev index next >