Author: epbernard
Date: 2009-06-22 14:09:41 -0400 (Mon, 22 Jun 2009)
New Revision: 16863
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/metadata/ElementDescriptor.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ElementDescriptorImpl.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/metadata/ElementDescriptorTest.java
Log:
BVAL-168 Return the list of matching ConstraintDescriptor for a given set of groups
BVAL-169 Rename ElementDescriptor.getType to getElementClass
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/metadata/ElementDescriptor.java
===================================================================
---
beanvalidation/trunk/validation-api/src/main/java/javax/validation/metadata/ElementDescriptor.java 2009-06-22
16:51:54 UTC (rev 16862)
+++
beanvalidation/trunk/validation-api/src/main/java/javax/validation/metadata/ElementDescriptor.java 2009-06-22
18:09:41 UTC (rev 16863)
@@ -34,10 +34,8 @@
/**
* @return Statically defined returned type.
- *
- * @todo should it be Type or even completly removed
*/
- Class<?> getType();
+ Class<?> getElementClass();
/**
* Return all constraint descriptors for this element or an
@@ -46,4 +44,17 @@
* @return Set of constraint descriptors for this element
*/
Set<ConstraintDescriptor<?>> getConstraintDescriptors();
+
+ /**
+ * Return the list of matching constraints for a given set of groups for this element.
+ *
+ * This method respects group sequences and group inheritance (including
+ * class-level Default group overriding) but does not return ConstraintDescriptors
+ * in any particular order. Specifically, ordering of the group sequence is not
+ * respected.
+ *
+ * @param groups groups targeted
+ * @return list of matching ConstraintDescriptors
+ */
+ Set<ConstraintDescriptor<?>>
getUnorderdConstraintDescriptorsMatchingGroups(Class<?>... groups);
}
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ElementDescriptorImpl.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ElementDescriptorImpl.java 2009-06-22
16:51:54 UTC (rev 16862)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ElementDescriptorImpl.java 2009-06-22
18:09:41 UTC (rev 16863)
@@ -51,7 +51,7 @@
/**
* {@inheritDoc}
*/
- public Class<?> getType() {
+ public Class<?> getElementClass() {
return type;
}
@@ -61,4 +61,11 @@
public Set<ConstraintDescriptor<?>> getConstraintDescriptors() {
return Collections.unmodifiableSet( constraintDescriptors );
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set<ConstraintDescriptor<?>>
getUnorderdConstraintDescriptorsMatchingGroups(Class<?>... groups) {
+ throw new UnsupportedOperationException( "Not yet implemented HV-176");
+ }
}
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/metadata/ElementDescriptorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/metadata/ElementDescriptorTest.java 2009-06-22
16:51:54 UTC (rev 16862)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/metadata/ElementDescriptorTest.java 2009-06-22
18:09:41 UTC (rev 16863)
@@ -41,13 +41,13 @@
public void testGetTypeForConstrainedBean() {
Validator validator = TestUtil.getValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
- assertEquals( beanDescriptor.getType(), Customer.class, "Wrong type." );
+ assertEquals( beanDescriptor.getElementClass(), Customer.class, "Wrong type."
);
}
@Test
public void testGetTypeForConstrainedProperty() {
ElementDescriptor elementDescriptor = TestUtil.getPropertyDescriptor( Order.class,
"orderNumber" );
- assertEquals( elementDescriptor.getType(), Integer.class, "Wrong type." );
+ assertEquals( elementDescriptor.getElementClass(), Integer.class, "Wrong
type." );
}
/**
Show replies by date