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

Print this page




 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 (p.getName().equals(getName()) &&
 290                 p.getType().equals(getType()) &&
 291                 p.getDescription().equals(getDescription()) &&
 292                 p.getDescriptor().equals(getDescriptor()) &&
 293                 p.isReadable() == isReadable() &&
 294                 p.isWritable() == isWritable() &&
 295                 p.isIs() == isIs());
 296     }
 297 
 298     /* We do not include everything in the hashcode.  We assume that
 299        if two operations are different they'll probably have different
 300        names or types.  The penalty we pay when this assumption is
 301        wrong should be less than the penalty we would pay if it were
 302        right and we needlessly hashed in the description and parameter
 303        array.  */
 304     public int hashCode() {
 305         return Objects.hash(getName(), getType());
 306     }
 307 
 308     private static boolean isIs(Method getter) {
 309         return (getter != null &&
 310                 getter.getName().startsWith("is") &&
 311                 (getter.getReturnType().equals(Boolean.TYPE) ||
 312                  getter.getReturnType().equals(Boolean.class)));




 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 
 298     /* We do not include everything in the hashcode.  We assume that
 299        if two operations are different they'll probably have different
 300        names or types.  The penalty we pay when this assumption is
 301        wrong should be less than the penalty we would pay if it were
 302        right and we needlessly hashed in the description and parameter
 303        array.  */
 304     public int hashCode() {
 305         return Objects.hash(getName(), getType());
 306     }
 307 
 308     private static boolean isIs(Method getter) {
 309         return (getter != null &&
 310                 getter.getName().startsWith("is") &&
 311                 (getter.getReturnType().equals(Boolean.TYPE) ||
 312                  getter.getReturnType().equals(Boolean.class)));