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

Print this page




 174 
 175     /**
 176      * Compare this MBeanConstructorInfo to another.
 177      *
 178      * @param o the object to compare to.
 179      *
 180      * @return true if and only if <code>o</code> is an MBeanConstructorInfo such
 181      * that its {@link #getName()}, {@link #getDescription()},
 182      * {@link #getSignature()}, and {@link #getDescriptor()}
 183      * values are equal (not necessarily
 184      * identical) to those of this MBeanConstructorInfo.  Two
 185      * signature arrays are equal if their elements are pairwise
 186      * equal.
 187      */
 188     public boolean equals(Object o) {
 189         if (o == this)
 190             return true;
 191         if (!(o instanceof MBeanConstructorInfo))
 192             return false;
 193         MBeanConstructorInfo p = (MBeanConstructorInfo) o;
 194         return (p.getName().equals(getName()) &&
 195                 p.getDescription().equals(getDescription()) &&
 196                 Arrays.equals(p.fastGetSignature(), fastGetSignature()) &&
 197                 p.getDescriptor().equals(getDescriptor()));
 198     }
 199 
 200     /* Unlike attributes and operations, it's quite likely we'll have
 201        more than one constructor with the same name and even
 202        description, so we include the parameter array in the hashcode.
 203        We don't include the description, though, because it could be
 204        quite long and yet the same between constructors.  Likewise for
 205        the descriptor.  */
 206     public int hashCode() {
 207         return Objects.hash(getName()) ^ Arrays.hashCode(fastGetSignature());
 208     }
 209 
 210     private static MBeanParameterInfo[] constructorSignature(Constructor<?> cn) {
 211         final Class<?>[] classes = cn.getParameterTypes();
 212         final Annotation[][] annots = cn.getParameterAnnotations();
 213         return MBeanOperationInfo.parameters(classes, annots);
 214     }
 215 }


 174 
 175     /**
 176      * Compare this MBeanConstructorInfo to another.
 177      *
 178      * @param o the object to compare to.
 179      *
 180      * @return true if and only if <code>o</code> is an MBeanConstructorInfo such
 181      * that its {@link #getName()}, {@link #getDescription()},
 182      * {@link #getSignature()}, and {@link #getDescriptor()}
 183      * values are equal (not necessarily
 184      * identical) to those of this MBeanConstructorInfo.  Two
 185      * signature arrays are equal if their elements are pairwise
 186      * equal.
 187      */
 188     public boolean equals(Object o) {
 189         if (o == this)
 190             return true;
 191         if (!(o instanceof MBeanConstructorInfo))
 192             return false;
 193         MBeanConstructorInfo p = (MBeanConstructorInfo) o;
 194         return (Objects.equals(p.getName(), getName()) &&
 195                 Objects.equals(p.getDescription(), getDescription()) &&
 196                 Arrays.equals(p.fastGetSignature(), fastGetSignature()) &&
 197                 Objects.equals(p.getDescriptor(), getDescriptor()));
 198     }
 199 
 200     /* Unlike attributes and operations, it's quite likely we'll have
 201        more than one constructor with the same name and even
 202        description, so we include the parameter array in the hashcode.
 203        We don't include the description, though, because it could be
 204        quite long and yet the same between constructors.  Likewise for
 205        the descriptor.  */
 206     public int hashCode() {
 207         return Objects.hash(getName()) ^ Arrays.hashCode(fastGetSignature());
 208     }
 209 
 210     private static MBeanParameterInfo[] constructorSignature(Constructor<?> cn) {
 211         final Class<?>[] classes = cn.getParameterTypes();
 212         final Annotation[][] annots = cn.getParameterAnnotations();
 213         return MBeanOperationInfo.parameters(classes, annots);
 214     }
 215 }