< prev index next >

src/java.desktop/share/classes/java/beans/PropertyDescriptor.java

Print this page




 471                     ctor = cls.getConstructor(new Class<?>[] { Object.class });
 472                 } catch (Exception ex) {
 473                     // Fall through
 474                 }
 475             }
 476             try {
 477                 if (ctor == null) {
 478                     editor = cls.newInstance();
 479                 } else {
 480                     editor = ctor.newInstance(new Object[] { bean });
 481                 }
 482             } catch (Exception ex) {
 483                 // Fall through
 484             }
 485         }
 486         return (PropertyEditor)editor;
 487     }
 488 
 489 
 490     /**
 491      * Compares this <code>PropertyDescriptor</code> against the specified object.
 492      * Returns true if the objects are the same. Two <code>PropertyDescriptor</code>s
 493      * are the same if the read, write, property types, property editor and
 494      * flags  are equivalent.
 495      *
 496      * @since 1.4
 497      */
 498     public boolean equals(Object obj) {
 499         if (this == obj) {
 500             return true;
 501         }
 502         if (obj != null && obj instanceof PropertyDescriptor) {
 503             PropertyDescriptor other = (PropertyDescriptor)obj;
 504             Method otherReadMethod = other.getReadMethod();
 505             Method otherWriteMethod = other.getWriteMethod();
 506 
 507             if (!compareMethods(getReadMethod(), otherReadMethod)) {
 508                 return false;
 509             }
 510 
 511             if (!compareMethods(getWriteMethod(), otherWriteMethod)) {
 512                 return false;




 471                     ctor = cls.getConstructor(new Class<?>[] { Object.class });
 472                 } catch (Exception ex) {
 473                     // Fall through
 474                 }
 475             }
 476             try {
 477                 if (ctor == null) {
 478                     editor = cls.newInstance();
 479                 } else {
 480                     editor = ctor.newInstance(new Object[] { bean });
 481                 }
 482             } catch (Exception ex) {
 483                 // Fall through
 484             }
 485         }
 486         return (PropertyEditor)editor;
 487     }
 488 
 489 
 490     /**
 491      * Compares this {@code PropertyDescriptor} against the specified object.
 492      * Returns true if the objects are the same. Two {@code PropertyDescriptor}s
 493      * are the same if the read, write, property types, property editor and
 494      * flags  are equivalent.
 495      *
 496      * @since 1.4
 497      */
 498     public boolean equals(Object obj) {
 499         if (this == obj) {
 500             return true;
 501         }
 502         if (obj != null && obj instanceof PropertyDescriptor) {
 503             PropertyDescriptor other = (PropertyDescriptor)obj;
 504             Method otherReadMethod = other.getReadMethod();
 505             Method otherWriteMethod = other.getWriteMethod();
 506 
 507             if (!compareMethods(getReadMethod(), otherReadMethod)) {
 508                 return false;
 509             }
 510 
 511             if (!compareMethods(getWriteMethod(), otherWriteMethod)) {
 512                 return false;


< prev index next >