Author: epbernard
Date: 2009-03-15 11:39:59 -0400 (Sun, 15 Mar 2009)
New Revision: 16159
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesAttribute.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcode.java
Log:
BVAL-138 BVAL-139 Rework @OverrideAttribute, various typos
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java
===================================================================
---
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java 2009-03-15
15:16:05 UTC (rev 16158)
+++
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java 2009-03-15
15:39:59 UTC (rev 16159)
@@ -30,19 +30,20 @@
*/
public interface ConstraintValidator<A extends Annotation, T> {
/**
- * Validator parameters for a given constraint declaration
- * Annotations parameters are passed as key/value into parameters
+ * Initialize the validator in preparation for isValid calls.
+ * The onstraint annotation for a given constraint declaration
+ * is passed.
* <p/>
* This method is guaranteed to be called before any of the other Constraint
* implementation methods
*
- * @param constraintAnnotation parameters for a given constraint declaration
+ * @param constraintAnnotation annotation instance for a given constraint declaration
*/
void initialize(A constraintAnnotation);
/**
* Implement the validation logic.
- * <code>value</code> state must not be changed by a Constraint
implementation
+ * <code>value</code> state must not be altered.
*
* @param value object to validate
* @param constraintValidatorContext context in which the constraint is evaluated
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java
===================================================================
---
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-03-15
15:16:05 UTC (rev 16158)
+++
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-03-15
15:39:59 UTC (rev 16159)
@@ -24,8 +24,8 @@
*/
public interface ConstraintValidatorContext {
/**
- * Disable default error message and default ConstraintViolation object generation.
- * Useful to set a different error message or generate an ConstraintViolation based on
+ * Disable the default error message and default ConstraintViolation object generation.
+ * Useful to set a different error message or generate a ConstraintViolation based on
* a different property
*
* @see #addError(String)
@@ -55,13 +55,21 @@
void addError(String message);
/**
- * Add a new error message to a given sub property <code>property</code>.
+ * Add a new error message to a given sub property <code>property</code>.
The subproperty
+ * is relative to the path tot he bean or property hosting the constraint.
+ *
* This error message will be interpolated.
* <p/>
* If <code>isValid</code> returns <code>false</code>, a
<code>ConstraintViolation</code> object will be built
* per error message including the default one unless {@link #disableDefaultError()}
* has been called.
* <p/>
+ * Aside from the error message and the property path,
<code>ConstraintViolation</code> objects
+ * generated from such a call contain the same contextual information
+ * (root bean, leaf bean etc)
+ * <p/>
+ * This method can be called multiple times. One
<code>ConstraintViolation</code> instance per
+ * call is created.
*
* @param message new uninterpolated error message.
* @param property property name the </code>ConstraintViolation</code> is
targeting.
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesAttribute.java
===================================================================
---
beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesAttribute.java 2009-03-15
15:16:05 UTC (rev 16158)
+++
beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesAttribute.java 2009-03-15
15:39:59 UTC (rev 16159)
@@ -40,11 +40,11 @@
/**
* Name of the Constraint attribute overridden.
- * Defaults to the name of the attribute hosting OverridesParameter.
+ * Defaults to the name of the attribute hosting OverridesAttribute.
*
* @return name of constraint attribute overridden.
*/
- String parameter();
+ String name();
/**
* The index of the targeted constraint declaration when using
@@ -56,7 +56,7 @@
*
* @return constraint declaration index if multivalued annotation is used
*/
- int index() default -1;
+ int constraintIndex() default -1;
/**
* Defines several @OverridesAttribute annotations on the same element
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java 2009-03-15
15:16:05 UTC (rev 16158)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java 2009-03-15
15:39:59 UTC (rev 16159)
@@ -244,13 +244,13 @@
private void addOverrideAttributes(Map<ClassIndexWrapper, Map<String,
Object>> overrideParameters, Object value, OverridesAttribute... attributes) {
for ( OverridesAttribute attribute : attributes ) {
- ClassIndexWrapper wrapper = new ClassIndexWrapper( attribute.constraint(),
attribute.index() );
+ ClassIndexWrapper wrapper = new ClassIndexWrapper( attribute.constraint(),
attribute.constraintIndex() );
Map<String, Object> map = overrideParameters.get( wrapper );
if ( map == null ) {
map = new HashMap<String, Object>();
overrideParameters.put( wrapper, map );
}
- map.put( attribute.parameter(), value );
+ map.put( attribute.name(), value );
}
}
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcode.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcode.java 2009-03-15
15:16:05 UTC (rev 16158)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcode.java 2009-03-15
15:39:59 UTC (rev 16159)
@@ -48,13 +48,13 @@
Class<?>[] groups() default { };
@OverridesAttribute.List({
- @OverridesAttribute(constraint = Size.class, parameter = "min"),
- @OverridesAttribute(constraint = Size.class, parameter = "max")
+ @OverridesAttribute(constraint = Size.class, name = "min"),
+ @OverridesAttribute(constraint = Size.class, name = "max")
}) int size() default 5;
@OverridesAttribute(constraint = Size.class,
- parameter = "message") String sizeMessage() default "A french zip code
has a length of 5";
+ name = "message") String sizeMessage() default "A french zip code has a
length of 5";
- @OverridesAttribute(constraint = Pattern.class, parameter = "regexp", index =
2) String regex() default "\\d*";
+ @OverridesAttribute(constraint = Pattern.class, name = "regexp",
constraintIndex = 2) String regex() default "\\d*";
}
Show replies by date