[hibernate-commits] Hibernate SVN: r15263 - validator/trunk/validation-api/src/main/java/javax/validation.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue Oct 7 17:22:00 EDT 2008


Author: epbernard
Date: 2008-10-07 17:22:00 -0400 (Tue, 07 Oct 2008)
New Revision: 15263

Added:
   validator/trunk/validation-api/src/main/java/javax/validation/OverridesParameter.java
   validator/trunk/validation-api/src/main/java/javax/validation/constraints/
Modified:
   validator/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java
Log:
BVAL-31 APIs for constraint composition

Modified: validator/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java	2008-10-07 21:08:17 UTC (rev 15262)
+++ validator/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java	2008-10-07 21:22:00 UTC (rev 15263)
@@ -29,6 +29,10 @@
  */
 public interface ConstraintDescriptor {
 	/**
+	 * Returns the annotation describing the constraint declaration.
+	 * If a composing constraint, parameter values are reflecting
+	 * the overridden parameters form the main constraint
+	 *
 	 * @return The annotation for this constraint.
 	 */
 	Annotation getAnnotation();
@@ -44,8 +48,22 @@
 	Constraint getConstraintImplementation();
 
 	/**
+	 * Returns a map containing the annotation paramter names as keys and the annotation parameter values
+	 * as value.
+	 * If a composing constraint, parameter values are reflecting
+	 * the overridden parameters form the main constraint
+	 *
 	 * @return Returns a map containing the annotation paramter names as keys and the annotation parameter values
 	 *         as value.
 	 */
 	Map<String, Object> getParameters();
+
+	/**
+	 * Return a set of ConstraintDescriptors. Each ConstraintDescriptor describes a composing
+	 * constraint. ConstraintDescriptor instances of composing constraints reflect overridden
+	 * parameter values in #getParameters() and #getAnnotation() 
+	 *
+	 * @return a set of ConstraintDescriptor object or an empty set
+	 */
+	Set<ConstraintDescriptor> getComposingConstraints();
 }

Added: validator/trunk/validation-api/src/main/java/javax/validation/OverridesParameter.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/OverridesParameter.java	                        (rev 0)
+++ validator/trunk/validation-api/src/main/java/javax/validation/OverridesParameter.java	2008-10-07 21:22:00 UTC (rev 15263)
@@ -0,0 +1,31 @@
+package javax.validation;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * Mark a parameter as overriding the parameter of a composing constraint.
+ * Both parameter must share the same type.
+ *
+ * @author Emmanuel Bernard
+ */
+public @interface OverridesParameter {
+	/**
+	 * constraint type the parameter is overriding
+	 */
+	Class<? extends Annotation> constraint();
+
+	/**
+	 * name of constraint parameter overridden  
+	 */
+	String parameter();
+
+	/**
+	 * index of the targetted constraint declaration when using
+	 * multiple constraints of the same type.
+	 * The index represent the index of the constraint in the value() array.
+	 *
+	 * By default, no index is defined and the single constraint declaration
+	 * is targeted
+	 */
+	int index() default -1;
+}




More information about the hibernate-commits mailing list