publicstaticvoid main(String[] args) { for (Class type : CLASSES) {
test(type);
}
}
privatestaticvoid test(Class type) { for (PropertyDescriptor pd : BeanUtils.getPropertyDescriptors(type)) {
PropertyDescriptor pdCopy = create(pd); if (pdCopy != null) { // XXX - hack! The Introspector will set the bound property // since it assumes that propertyChange event set descriptors // infers that all the properties are bound
pdCopy.setBound(pd.isBound());
String name = pd.getName();
System.out.println(" - " + name);
if (!compare(pd, pdCopy)) thrownew Error("property delegates are not equal");
if (!pd.equals(pdCopy)) thrownew Error("equals() failed");
if (pd.hashCode() != pdCopy.hashCode()) thrownew Error("hashCode() failed");
}
}
}
privatestaticboolean compare(PropertyDescriptor pd1, PropertyDescriptor pd2) { if (!compare(pd1.getReadMethod(), pd2.getReadMethod())) {
System.out.println("read methods not equal"); returnfalse;
} if (!compare(pd1.getWriteMethod(), pd2.getWriteMethod())) {
System.out.println("write methods not equal"); returnfalse;
} if (pd1.getPropertyType() != pd2.getPropertyType()) {
System.out.println("property type not equal"); returnfalse;
} if (pd1.getPropertyEditorClass() != pd2.getPropertyEditorClass()) {
System.out.println("property editor class not equal"); returnfalse;
} if (pd1.isBound() != pd2.isBound()) {
System.out.println("bound value not equal"); returnfalse;
} if (pd1.isConstrained() != pd2.isConstrained()) {
System.out.println("constrained value not equal"); returnfalse;
} returntrue;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.