emmanuel wrote:
FroMage wrote:
Page 68 wouldn't it make it easier to use if BeanDescriptor had a getTypeConstraints() or getBeanConstraints() or getClassConstraints() (however it is named) which returns the class-level constraints? It seems to be missing and since there is a hasConstraints() method there, it seems fitting to include them there.
I suspect they would be included from the ElementDescriptor.getConstraintDescriptors() but still, why make this harder than for property constraints?
ElementDescriptor.getConstraintDescriptor() does return the element level constraints. This is true for BeanDescriptor, PropertyDescriptor, Parameterdescriptor etc. not sure why you think it's different between proeprty and bean.
BTW I am planning to move hasConstraints() up to ElementDescriptor
Aha, so the BeanDescriptor.getConstraintDescriptors(); only lists class-level constraints, in order to get to the property constraints we have to use BeanDescriptor.getConstraintsForProperty(...).getConstraintDescriptors().
Now I get it, it totally makes sense.
I was misled by ElementDescriptor.getConstraintDescriptors()'s javadoc which says "Returns all the constraint descriptors for this element." In my mind, the list of constraints on a bean included both the class-level and property-level constraints. This is just me making invalid assumptions.