Hibernate SVN: r17598 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-09-30 16:27:35 -0400 (Wed, 30 Sep 2009)
New Revision: 17598
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintTree.java
Log:
HV-242
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintTree.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintTree.java 2009-09-30 19:36:08 UTC (rev 17597)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintTree.java 2009-09-30 20:27:35 UTC (rev 17598)
@@ -20,10 +20,10 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorFactory;
import javax.validation.ConstraintViolation;
@@ -51,7 +51,7 @@
private final List<ConstraintTree<?>> children;
private final ConstraintDescriptor<A> descriptor;
- private final Map<Class<? extends ConstraintValidator<?, ?>>, ConstraintValidator<A, ?>> constraintValidatorCache;
+ private final Map<ValidatorCacheKey, ConstraintValidator<A, ?>> constraintValidatorCache;
public ConstraintTree(ConstraintDescriptor<A> descriptor) {
this( descriptor, null );
@@ -60,7 +60,7 @@
private ConstraintTree(ConstraintDescriptor<A> descriptor, ConstraintTree<?> parent) {
this.parent = parent;
this.descriptor = descriptor;
- this.constraintValidatorCache = new HashMap<Class<? extends ConstraintValidator<?, ?>>, ConstraintValidator<A, ?>>();
+ this.constraintValidatorCache = new ConcurrentHashMap<ValidatorCacheKey, ConstraintValidator<A, ?>>();
final Set<ConstraintDescriptor<?>> composingConstraints = descriptor.getComposingConstraints();
children = new ArrayList<ConstraintTree<?>>( composingConstraints.size() );
@@ -174,26 +174,37 @@
private <V> ConstraintValidator<A, V> getInitializedValidator(Type type, ConstraintValidatorFactory constraintFactory) {
Class<? extends ConstraintValidator<?, ?>> validatorClass = findMatchingValidatorClass( type );
+ // check if we have the default validator factory. If not we don't use caching (see HV-242)
+ if(! (constraintFactory instanceof ConstraintValidatorFactoryImpl)) {
+ return createAndInitializeValidator( constraintFactory, validatorClass );
+ }
+
ConstraintValidator<A, V> constraintValidator;
-
- if ( !constraintValidatorCache.containsKey( validatorClass ) ) {
- constraintValidator = ( ConstraintValidator<A, V> ) constraintFactory.getInstance(
- validatorClass
- );
- if ( constraintValidator == null ) {
- throw new ValidationException(
- "Constraint factory returned null when trying to create instance of " + validatorClass.getName()
- );
- }
- constraintValidatorCache.put( validatorClass, constraintValidator );
+ ValidatorCacheKey key = new ValidatorCacheKey( constraintFactory, validatorClass );
+ if ( !constraintValidatorCache.containsKey( key ) ) {
+ constraintValidator = createAndInitializeValidator( constraintFactory, validatorClass );
+ constraintValidatorCache.put( key, constraintValidator );
}
else {
if ( log.isTraceEnabled() ) {
log.trace( "Constraint validator {} found in cache" );
}
- constraintValidator = ( ConstraintValidator<A, V> ) constraintValidatorCache.get( validatorClass );
+ constraintValidator = ( ConstraintValidator<A, V> ) constraintValidatorCache.get( key );
}
+ return constraintValidator;
+ }
+ @SuppressWarnings("unchecked")
+ private <V> ConstraintValidator<A, V> createAndInitializeValidator(ConstraintValidatorFactory constraintFactory, Class<? extends ConstraintValidator<?, ?>> validatorClass) {
+ ConstraintValidator<A, V> constraintValidator;
+ constraintValidator = ( ConstraintValidator<A, V> ) constraintFactory.getInstance(
+ validatorClass
+ );
+ if ( constraintValidator == null ) {
+ throw new ValidationException(
+ "Constraint factory returned null when trying to create instance of " + validatorClass.getName()
+ );
+ }
initializeConstraint( descriptor, constraintValidator );
return constraintValidator;
}
@@ -303,4 +314,42 @@
sb.append( '}' );
return sb.toString();
}
+
+ private static class ValidatorCacheKey {
+ private ConstraintValidatorFactory constraintValidatorFactory;
+ private Class<? extends ConstraintValidator<?, ?>> validatorType;
+
+ private ValidatorCacheKey(ConstraintValidatorFactory constraintValidatorFactory, Class<? extends ConstraintValidator<?, ?>> validatorType) {
+ this.constraintValidatorFactory = constraintValidatorFactory;
+ this.validatorType = validatorType;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() ) {
+ return false;
+ }
+
+ ValidatorCacheKey that = ( ValidatorCacheKey ) o;
+
+ if ( constraintValidatorFactory != null ? !constraintValidatorFactory.equals( that.constraintValidatorFactory ) : that.constraintValidatorFactory != null ) {
+ return false;
+ }
+ if ( validatorType != null ? !validatorType.equals( that.validatorType ) : that.validatorType != null ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = constraintValidatorFactory != null ? constraintValidatorFactory.hashCode() : 0;
+ result = 31 * result + ( validatorType != null ? validatorType.hashCode() : 0 );
+ return result;
+ }
+ }
}
15 years, 2 months
Now you can earn more
by Garfield Lecuyer
Now you can obtain a degree in just 4-5 weeks on the base of your professional career
We provide the following programs:-
Masters, Bachelors and PhD
Give us a call now.
1-816-292-2839
Leave a msg, with your full name and contact number so we can call you back.
15 years, 2 months
Hibernate SVN: r17597 - beanvalidation/api/trunk/src/main/java/javax/validation.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-09-30 15:36:08 -0400 (Wed, 30 Sep 2009)
New Revision: 17597
Modified:
beanvalidation/api/trunk/src/main/java/javax/validation/ConstraintValidatorContext.java
Log:
BVAL-186 Clarify method names on the constraint violation builder DSL of ConstraintValidatorContext
Modified: beanvalidation/api/trunk/src/main/java/javax/validation/ConstraintValidatorContext.java
===================================================================
--- beanvalidation/api/trunk/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-09-30 19:28:08 UTC (rev 17596)
+++ beanvalidation/api/trunk/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-09-30 19:36:08 UTC (rev 17597)
@@ -108,7 +108,7 @@
* Add a node to the path the <code>ConstraintViolation</code> will be associated to.
*
* <code>name</code> describes a single property. In particular,
- * dot (.) are not allowed.
+ * dot (.) is not allowed.
*
* @param name property name
* @return a builder representing node <code>name</code>
15 years, 2 months
Hibernate SVN: r17596 - beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-09-30 15:28:08 -0400 (Wed, 30 Sep 2009)
New Revision: 17596
Modified:
beanvalidation/api/trunk/src/main/java/javax/validation/ConstraintValidatorContext.java
beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcodeConstraintValidator.java
beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintValidatorContextImpl.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/StartLessThanEndImpl.java
Log:
BVAL-186 Clarify method names on the constraint violation builder DSL of ConstraintValidatorContext
Modified: beanvalidation/api/trunk/src/main/java/javax/validation/ConstraintValidatorContext.java
===================================================================
--- beanvalidation/api/trunk/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-09-30 19:24:02 UTC (rev 17595)
+++ beanvalidation/api/trunk/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-09-30 19:28:08 UTC (rev 17596)
@@ -27,8 +27,8 @@
*/
public interface ConstraintValidatorContext {
/**
- * Disable the default <code>ConstraintViolation</code> object generation using the
- * declared message template.
+ * Disable the default <code>ConstraintViolation</code> object generation (which
+ * is using the message template declared on the constraint).
* Useful to set a different violation message or generate a <code>ConstraintViolation</Code>
* based on a different property.
*/
@@ -66,18 +66,18 @@
* <pre>
* {@code
* // create new violation report with the default path the constraint is located on
- * context.buildConstraintViolationWithMessageTemplate( "way too long" )
+ * context.buildConstraintViolationWithTemplate( "way too long" )
* .addConstraintViolation();
*
* // create new violation report in the "street" subnode of the default path
* //the constraint is located on
- * context.buildConstraintViolationWithMessageTemplate( "way too long" )
+ * context.buildConstraintViolationWithTemplate( "way too long" )
* .addNode( "street" )
* .addConstraintViolation();
*
* //create new violation report in the "addresses["home"].city.name" subnode
* //of the default path the constraint is located on
- * context.buildConstraintViolationWithMessageTemplate( "this detail is wrong" )
+ * context.buildConstraintViolationWithTemplate( "this detail is wrong" )
* .addNode( "addresses" )
* .addNode( "country" )
* .inIterable().atKey( "home" )
@@ -89,7 +89,7 @@
* @param messageTemplate new uninterpolated constraint message.
* @return Returns an constraint violation builder
*/
- ConstraintViolationBuilder buildConstraintViolationWithMessageTemplate(String messageTemplate);
+ ConstraintViolationBuilder buildConstraintViolationWithTemplate(String messageTemplate);
/**
* <code>ConstraintViolation</code> builder allowing to optionally associate
Modified: beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcodeConstraintValidator.java
===================================================================
--- beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcodeConstraintValidator.java 2009-09-30 19:24:02 UTC (rev 17595)
+++ beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcodeConstraintValidator.java 2009-09-30 19:28:08 UTC (rev 17596)
@@ -34,7 +34,7 @@
}
if ( "00000".equals( zip ) ) {
constraintValidatorContext.disableDefaultConstraintViolation();
- constraintValidatorContext.buildConstraintViolationWithMessageTemplate( "00000 is a reserved code" ).addConstraintViolation();
+ constraintValidatorContext.buildConstraintViolationWithTemplate( "00000 is a reserved code" ).addConstraintViolation();
return false;
}
else {
Modified: beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java
===================================================================
--- beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java 2009-09-30 19:24:02 UTC (rev 17595)
+++ beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java 2009-09-30 19:28:08 UTC (rev 17596)
@@ -42,10 +42,10 @@
if ( errorMessages != null ) {
for ( Map.Entry<String, String> entry : errorMessages.entrySet() ) {
if ( entry.getKey() == null ) {
- constraintValidatorContext.buildConstraintViolationWithMessageTemplate( entry.getValue() ).addConstraintViolation();
+ constraintValidatorContext.buildConstraintViolationWithTemplate( entry.getValue() ).addConstraintViolation();
}
else {
- constraintValidatorContext.buildConstraintViolationWithMessageTemplate( entry.getValue() )
+ constraintValidatorContext.buildConstraintViolationWithTemplate( entry.getValue() )
.addNode( entry.getKey() )
.addConstraintViolation();
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintValidatorContextImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintValidatorContextImpl.java 2009-09-30 19:24:02 UTC (rev 17595)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintValidatorContextImpl.java 2009-09-30 19:28:08 UTC (rev 17596)
@@ -48,7 +48,7 @@
return ( String ) constraintDescriptor.getAttributes().get( "message" );
}
- public ConstraintViolationBuilder buildConstraintViolationWithMessageTemplate(String messageTemplate) {
+ public ConstraintViolationBuilder buildConstraintViolationWithTemplate(String messageTemplate) {
return new ErrorBuilderImpl( messageTemplate, propertyPath );
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/StartLessThanEndImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/StartLessThanEndImpl.java 2009-09-30 19:24:02 UTC (rev 17595)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/StartLessThanEndImpl.java 2009-09-30 19:28:08 UTC (rev 17596)
@@ -31,7 +31,7 @@
public boolean isValid(Interval value, ConstraintValidatorContext c) {
if ( value.start > value.end ) {
c.disableDefaultConstraintViolation();
- c.buildConstraintViolationWithMessageTemplate( c.getDefaultConstraintMessageTemplate() ).addNode( "start" ).addConstraintViolation();
+ c.buildConstraintViolationWithTemplate( c.getDefaultConstraintMessageTemplate() ).addNode( "start" ).addConstraintViolation();
return false;
}
return true;
15 years, 2 months
Hibernate SVN: r17595 - beanvalidation/tck/trunk.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-09-30 15:24:02 -0400 (Wed, 30 Sep 2009)
New Revision: 17595
Modified:
beanvalidation/tck/trunk/pom.xml
Log:
updated the tck audit dep
Modified: beanvalidation/tck/trunk/pom.xml
===================================================================
--- beanvalidation/tck/trunk/pom.xml 2009-09-30 18:47:39 UTC (rev 17594)
+++ beanvalidation/tck/trunk/pom.xml 2009-09-30 19:24:02 UTC (rev 17595)
@@ -49,7 +49,7 @@
<dependency>
<groupId>org.jboss.test-audit</groupId>
<artifactId>jboss-test-audit-api</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.jboss.test-harness</groupId>
15 years, 2 months
Thank you for setting the order No.475456
by Sherry Seay
Dear Customer!
Thank you for ordering at our online store.
Your order: Sony VAIO A1133651A, was sent at your address.
The tracking number of your postal parcel is indicated in the document attached to this letter.
Please, print out the postal label for receiving the parcel.
Internet Store.
15 years, 2 months
Hibernate SVN: r17594 - beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-09-30 14:47:39 -0400 (Wed, 30 Sep 2009)
New Revision: 17594
Modified:
beanvalidation/api/trunk/src/main/java/javax/validation/ConstraintValidatorContext.java
beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcodeConstraintValidator.java
beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintValidatorContextImpl.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/StartLessThanEndImpl.java
Log:
BVAL-186 Clarify method names on the constraint violation builder DSL of ConstraintValidatorContext
Modified: beanvalidation/api/trunk/src/main/java/javax/validation/ConstraintValidatorContext.java
===================================================================
--- beanvalidation/api/trunk/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-09-30 18:29:48 UTC (rev 17593)
+++ beanvalidation/api/trunk/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-09-30 18:47:39 UTC (rev 17594)
@@ -20,92 +20,92 @@
/**
* Provide contextual data and operation when applying a given constraint validator.
*
- * At least one error must be defined (either the default one, of if the default error
- * is disabled, a custom one).
+ * At least one <code>ConstraintViolation</code> must be defined (either the default one,
+ * of if the default <code>ConstraintViolation</code> is disabled, a custom one).
*
* @author Emmanuel Bernard
*/
public interface ConstraintValidatorContext {
/**
- * Disable the default error message and default <code>ConstraintViolation</code> object
- * generation.
- * Useful to set a different error message or generate a <code>ConstraintViolation</Code>
- * based on a different property
+ * Disable the default <code>ConstraintViolation</code> object generation using the
+ * declared message template.
+ * Useful to set a different violation message or generate a <code>ConstraintViolation</Code>
+ * based on a different property.
*/
- void disableDefaultError();
+ void disableDefaultConstraintViolation();
/**
- * @return the current uninterpolated default message
+ * @return the current uninterpolated default message.
*/
- String getDefaultErrorMessageTemplate();
+ String getDefaultConstraintMessageTemplate();
/**
- * Return an error builder building an error allowing to optionally associate
- * the error to a sub path.
- * The error message will be interpolated.
+ * Return an constraint violation builder building an violation report
+ * allowing to optionally associate it to a sub path.
+ * The violation message will be interpolated.
* <p/>
- * To create the error, one must call either one of
- * the #addError method available in one of the
+ * To create the <code>ConstraintViolation</code>, one must call either one of
+ * the #addConstraintViolation() methods available in one of the
* interfaces of the fluent API.
- * If another method is called after #addError() on
- * <code>ErrorBuilder</code> or any of its associated nested interfaces
+ * If another method is called after #addConstraintViolation() on
+ * <code>ConstraintViolationBuilder</code> or any of its associated nested interfaces
* an <code>IllegalStateException</code> is raised.
* <p/>
* If <code>isValid<code> returns <code>false</code>, a <code>ConstraintViolation</code>
- * object will be built per error including the default one (unless
- * {@link #disableDefaultError()} has been called).
+ * object will be built per ConstraintViolation report including the default one (unless
+ * {@link #disableDefaultConstraintViolation()} has been called).
* <p/>
* <code>ConstraintViolation</code> objects generated from such a call
* contain the same contextual information (root bean, path and so on) unless
* the path has been overriden.
* <p/>
- * To create a different error, a new error builder has to be retrieved from
- * <code>ConstraintValidatorContext</code>
+ * To create a different <code>ConstraintViolation</code>, a new constraint violation builder
+ * has to be retrieved from <code>ConstraintValidatorContext</code>
*
* Here are a few usage examples:
* <pre>
* {@code
- * // create new error with the default path the constraint is located on
- * context.buildErrorWithMessageTemplate( "way too long" )
- * .addError();
+ * // create new violation report with the default path the constraint is located on
+ * context.buildConstraintViolationWithMessageTemplate( "way too long" )
+ * .addConstraintViolation();
*
- * // create new error in the "street" subnode of the default path the constraint
- * // is located on
- * context.buildErrorWithMessageTemplate( "way too long" )
- * .addSubNode( "street" )
- * .addError();
+ * // create new violation report in the "street" subnode of the default path
+ * //the constraint is located on
+ * context.buildConstraintViolationWithMessageTemplate( "way too long" )
+ * .addNode( "street" )
+ * .addConstraintViolation();
*
- * //create new error in the "addresses["home"].city.name" subnode of the default
- * // path the constraint is located on
- * context.buildErrorWithMessageTemplate( "this detail is wrong" )
- * .addSubNode( "addresses" )
- * .addSubNode( "country" )
+ * //create new violation report in the "addresses["home"].city.name" subnode
+ * //of the default path the constraint is located on
+ * context.buildConstraintViolationWithMessageTemplate( "this detail is wrong" )
+ * .addNode( "addresses" )
+ * .addNode( "country" )
* .inIterable().atKey( "home" )
- * .addSubNode( "name" )
- * .addError();
+ * .addNode( "name" )
+ * .addConstraintViolation();
* }
* </pre>
*
- * @param messageTemplate new uninterpolated error message.
- * @return Returns an error builder
+ * @param messageTemplate new uninterpolated constraint message.
+ * @return Returns an constraint violation builder
*/
- ErrorBuilder buildErrorWithMessageTemplate(String messageTemplate);
+ ConstraintViolationBuilder buildConstraintViolationWithMessageTemplate(String messageTemplate);
/**
- * Error builder allowing to optionally associate
- * the error to a sub path.
+ * <code>ConstraintViolation</code> builder allowing to optionally associate
+ * the violation report to a sub path.
*
- * To create the error, one must call either one of
- * the #addError method available in one of the
+ * To create the <code>ConstraintViolation</code>, one must call either one of
+ * the #addConstraintViolation() methods available in one of the
* interfaces of the fluent API.
- * If another method is called after #addError() on
- * <code>ErrorBuilder</code> or any of its associated objects
+ * If another method is called after #addConstraintViolation() on
+ * <code>ConstraintViolationBuilder</code> or any of its associated objects
* an <code>IllegalStateException</code> is raised.
*
*/
- interface ErrorBuilder {
+ interface ConstraintViolationBuilder {
/**
- * Add a subNode to the path the error will be associated to.
+ * Add a node to the path the <code>ConstraintViolation</code> will be associated to.
*
* <code>name</code> describes a single property. In particular,
* dot (.) are not allowed.
@@ -113,26 +113,27 @@
* @param name property name
* @return a builder representing node <code>name</code>
*/
- NodeBuilderDefinedContext addSubNode(String name);
+ NodeBuilderDefinedContext addNode(String name);
/**
- * Add the new error report to be generated if the
+ * Add the new <code>ConstraintViolation</code> to be generated if the
* constraint validator marks the value as invalid.
- * Methods of this <code>ErrorBuilder</code> instance and its nested
- * objects returns <code>IllegalStateException</code> from now on.
+ * Methods of this <code>ConstraintViolationBuilder</code> instance and its nested
+ * objects return <code>IllegalStateException</code> from now on.
*
- * @return the ConstraintValidatorContext instance the ErrorBuilder comes from
+ * @return the <code>ConstraintValidatorContext</code> instance the
+ * <code>ConstraintViolationBuilder</code> comes from
*/
- ConstraintValidatorContext addError();
+ ConstraintValidatorContext addConstraintViolation();
/**
- * Represent a subnode whose context is known
+ * Represent a node whose context is known
* (ie index, key and isInIterable)
*/
interface NodeBuilderDefinedContext {
/**
- * Add a subNode to the path the error will be associated to.
+ * Add a node to the path the <code>ConstraintViolation</code> will be associated to.
*
* <code>name</code> describes a single property. In particular,
* dot (.) are not allowed.
@@ -140,22 +141,23 @@
* @param name property <code>name</code>
* @return a builder representing this node
*/
- NodeBuilderCustomizableContext addSubNode(String name);
+ NodeBuilderCustomizableContext addNode(String name);
/**
- * Add the new error report to be generated if the
+ * Add the new <code>ConstraintViolation</code> to be generated if the
* constraint validator marks the value as invalid.
- * Methods of the <code>ErrorBuilder</code> instance this object comes
- * from and the error builder nested
- * objects returns <code>IllegalStateException</code> after this call.
+ * Methods of the <code>ConstraintViolationBuilder</code> instance this object
+ * comes from and the constraint violation builder nested
+ * objects return <code>IllegalStateException</code> after this call.
*
- * @return ConstraintValidatorContext instance the ErrorBuilder comes from
+ * @return <code>ConstraintValidatorContext</code> instance the
+ * <code>ConstraintViolationBuilder</code> comes from
*/
- ConstraintValidatorContext addError();
+ ConstraintValidatorContext addConstraintViolation();
}
/**
- * Represent a subnode whose context is
+ * Represent a node whose context is
* configurable (ie index, key and isInIterable)
*/
interface NodeBuilderCustomizableContext {
@@ -168,7 +170,7 @@
NodeContextBuilder inIterable();
/**
- * Add a subNode to the path the error will be associated to.
+ * Add a node to the path the <code>ConstraintViolation</code> will be associated to.
*
* <code>name</code> describes a single property. In particular,
* dot (.) are not allowed.
@@ -176,18 +178,19 @@
* @param name property <code>name</code>
* @return a builder representing this node
*/
- NodeBuilderCustomizableContext addSubNode(String name);
+ NodeBuilderCustomizableContext addNode(String name);
/**
- * Add the new error report to be generated if the
+ * Add the new <code>ConstraintViolation</code> to be generated if the
* constraint validator mark the value as invalid.
- * Methods of the <code>ErrorBuilder</code> instance this object comes
- * from and the error builder nested
- * objects returns <code>IllegalStateException</code> after this call.
+ * Methods of the <code>ConstraintViolationBuilder</code> instance this object
+ * comes from and the constraint violation builder nested
+ * objects return <code>IllegalStateException</code> after this call.
*
- * @return ConstraintValidatorContext instance the ErrorBuilder comes from
+ * @return <code>ConstraintValidatorContext</code> instance the
+ * <code>ConstraintViolationBuilder</code> comes from
*/
- ConstraintValidatorContext addError();
+ ConstraintValidatorContext addConstraintViolation();
}
/**
@@ -215,7 +218,7 @@
NodeBuilderDefinedContext atIndex(Integer index);
/**
- * Add a subNode to the path the error will be associated to.
+ * Add a node to the path the <code>ConstraintViolation</code> will be associated to.
*
* <code>name</code> describes a single property. In particular,
* dot (.) are not allowed.
@@ -223,18 +226,19 @@
* @param name property <code>name</code>
* @return a builder representing this node
*/
- NodeBuilderCustomizableContext addSubNode(String name);
+ NodeBuilderCustomizableContext addNode(String name);
/**
- * Add the new error report to be generated if the
+ * Add the new <code>ConstraintViolation</code> to be generated if the
* constraint validator mark the value as invalid.
- * Methods of the <code>ErrorBuilder</code> instance this object comes
- * from and the error builder nested
- * objects returns <code>IllegalStateException</code> after this call.
+ * Methods of the <code>ConstraintViolationBuilder</code> instance this object
+ * comes from and the constraint violation builder nested
+ * objects return <code>IllegalStateException</code> after this call.
*
- * @return ConstraintValidatorContext instance the ErrorBuilder comes from
+ * @return <code>ConstraintValidatorContext</code> instance the
+ * <code>ConstraintViolationBuilder</code> comes from
*/
- ConstraintValidatorContext addError();
+ ConstraintValidatorContext addConstraintViolation();
}
}
}
Modified: beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcodeConstraintValidator.java
===================================================================
--- beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcodeConstraintValidator.java 2009-09-30 18:29:48 UTC (rev 17593)
+++ beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcodeConstraintValidator.java 2009-09-30 18:47:39 UTC (rev 17594)
@@ -33,8 +33,8 @@
return true;
}
if ( "00000".equals( zip ) ) {
- constraintValidatorContext.disableDefaultError();
- constraintValidatorContext.buildErrorWithMessageTemplate( "00000 is a reserved code" ).addError();
+ constraintValidatorContext.disableDefaultConstraintViolation();
+ constraintValidatorContext.buildConstraintViolationWithMessageTemplate( "00000 is a reserved code" ).addConstraintViolation();
return false;
}
else {
Modified: beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java
===================================================================
--- beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java 2009-09-30 18:29:48 UTC (rev 17593)
+++ beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java 2009-09-30 18:47:39 UTC (rev 17594)
@@ -36,18 +36,18 @@
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
if ( disableDefaultError ) {
- constraintValidatorContext.disableDefaultError();
+ constraintValidatorContext.disableDefaultConstraintViolation();
}
if ( errorMessages != null ) {
for ( Map.Entry<String, String> entry : errorMessages.entrySet() ) {
if ( entry.getKey() == null ) {
- constraintValidatorContext.buildErrorWithMessageTemplate( entry.getValue() ).addError();
+ constraintValidatorContext.buildConstraintViolationWithMessageTemplate( entry.getValue() ).addConstraintViolation();
}
else {
- constraintValidatorContext.buildErrorWithMessageTemplate( entry.getValue() )
- .addSubNode( entry.getKey() )
- .addError();
+ constraintValidatorContext.buildConstraintViolationWithMessageTemplate( entry.getValue() )
+ .addNode( entry.getKey() )
+ .addConstraintViolation();
}
}
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintValidatorContextImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintValidatorContextImpl.java 2009-09-30 18:29:48 UTC (rev 17593)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintValidatorContextImpl.java 2009-09-30 18:47:39 UTC (rev 17594)
@@ -40,15 +40,15 @@
this.constraintDescriptor = constraintDescriptor;
}
- public void disableDefaultError() {
+ public void disableDefaultConstraintViolation() {
defaultDisabled = true;
}
- public String getDefaultErrorMessageTemplate() {
+ public String getDefaultConstraintMessageTemplate() {
return ( String ) constraintDescriptor.getAttributes().get( "message" );
}
- public ErrorBuilder buildErrorWithMessageTemplate(String messageTemplate) {
+ public ConstraintViolationBuilder buildConstraintViolationWithMessageTemplate(String messageTemplate) {
return new ErrorBuilderImpl( messageTemplate, propertyPath );
}
@@ -64,7 +64,7 @@
List<ErrorMessage> returnedErrorMessages = new ArrayList<ErrorMessage>( errorMessages );
if ( !defaultDisabled ) {
returnedErrorMessages.add(
- new ErrorMessage( getDefaultErrorMessageTemplate(), propertyPath )
+ new ErrorMessage( getDefaultConstraintMessageTemplate(), propertyPath )
);
}
return returnedErrorMessages;
@@ -88,7 +88,7 @@
}
}
- class ErrorBuilderImpl implements ErrorBuilder {
+ class ErrorBuilderImpl implements ConstraintViolationBuilder {
String messageTemplate;
PathImpl propertyPath;
@@ -97,7 +97,7 @@
propertyPath = path;
}
- public NodeBuilderDefinedContext addSubNode(String name) {
+ public NodeBuilderDefinedContext addNode(String name) {
PathImpl path;
if ( propertyPath.isRootPath() ) {
path = PathImpl.createNewPath( name );
@@ -109,13 +109,13 @@
return new NodeBuilderImpl( messageTemplate, path );
}
- public ConstraintValidatorContext addError() {
+ public ConstraintValidatorContext addConstraintViolation() {
errorMessages.add( new ErrorMessage( messageTemplate, propertyPath ) );
return ConstraintValidatorContextImpl.this;
}
}
- class NodeBuilderImpl implements ErrorBuilder.NodeBuilderDefinedContext {
+ class NodeBuilderImpl implements ConstraintViolationBuilder.NodeBuilderDefinedContext {
String messageTemplate;
PathImpl propertyPath;
@@ -124,19 +124,19 @@
propertyPath = path;
}
- public ErrorBuilder.NodeBuilderCustomizableContext addSubNode(String name) {
+ public ConstraintViolationBuilder.NodeBuilderCustomizableContext addNode(String name) {
NodeImpl node = new NodeImpl( name );
propertyPath.addNode( node );
return new InIterableNodeBuilderImpl( messageTemplate, propertyPath );
}
- public ConstraintValidatorContext addError() {
+ public ConstraintValidatorContext addConstraintViolation() {
errorMessages.add( new ErrorMessage( messageTemplate, propertyPath ) );
return ConstraintValidatorContextImpl.this;
}
}
- class InIterableNodeBuilderImpl implements ErrorBuilder.NodeBuilderCustomizableContext {
+ class InIterableNodeBuilderImpl implements ConstraintViolationBuilder.NodeBuilderCustomizableContext {
String messageTemplate;
PathImpl propertyPath;
@@ -145,23 +145,23 @@
propertyPath = path;
}
- public ErrorBuilder.NodeContextBuilder inIterable() {
+ public ConstraintViolationBuilder.NodeContextBuilder inIterable() {
return new InIterablePropertiesBuilderImpl( messageTemplate, propertyPath );
}
- public ErrorBuilder.NodeBuilderCustomizableContext addSubNode(String name) {
+ public ConstraintViolationBuilder.NodeBuilderCustomizableContext addNode(String name) {
Path.Node node = new NodeImpl( name );
propertyPath.addNode( node );
return this;
}
- public ConstraintValidatorContext addError() {
+ public ConstraintValidatorContext addConstraintViolation() {
errorMessages.add( new ErrorMessage( messageTemplate, propertyPath ) );
return ConstraintValidatorContextImpl.this;
}
}
- class InIterablePropertiesBuilderImpl implements ErrorBuilder.NodeContextBuilder {
+ class InIterablePropertiesBuilderImpl implements ConstraintViolationBuilder.NodeContextBuilder {
String messageTemplate;
PathImpl propertyPath;
@@ -171,23 +171,23 @@
propertyPath.getLeafNode().setInIterable( true );
}
- public ErrorBuilder.NodeBuilderDefinedContext atKey(Object key) {
+ public ConstraintViolationBuilder.NodeBuilderDefinedContext atKey(Object key) {
propertyPath.getLeafNode().setKey( key );
return new NodeBuilderImpl( messageTemplate, propertyPath );
}
- public ErrorBuilder.NodeBuilderDefinedContext atIndex(Integer index) {
+ public ConstraintViolationBuilder.NodeBuilderDefinedContext atIndex(Integer index) {
propertyPath.getLeafNode().setIndex( index );
return new NodeBuilderImpl( messageTemplate, propertyPath );
}
- public ErrorBuilder.NodeBuilderCustomizableContext addSubNode(String name) {
+ public ConstraintViolationBuilder.NodeBuilderCustomizableContext addNode(String name) {
Path.Node node = new NodeImpl( name );
propertyPath.addNode( node );
return new InIterableNodeBuilderImpl( messageTemplate, propertyPath );
}
- public ConstraintValidatorContext addError() {
+ public ConstraintValidatorContext addConstraintViolation() {
errorMessages.add( new ErrorMessage( messageTemplate, propertyPath ) );
return ConstraintValidatorContextImpl.this;
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/StartLessThanEndImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/StartLessThanEndImpl.java 2009-09-30 18:29:48 UTC (rev 17593)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/StartLessThanEndImpl.java 2009-09-30 18:47:39 UTC (rev 17594)
@@ -30,8 +30,8 @@
public boolean isValid(Interval value, ConstraintValidatorContext c) {
if ( value.start > value.end ) {
- c.disableDefaultError();
- c.buildErrorWithMessageTemplate( c.getDefaultErrorMessageTemplate() ).addSubNode( "start" ).addError();
+ c.disableDefaultConstraintViolation();
+ c.buildConstraintViolationWithMessageTemplate( c.getDefaultConstraintMessageTemplate() ).addNode( "start" ).addConstraintViolation();
return false;
}
return true;
15 years, 2 months
Hibernate SVN: r17593 - in beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints: groups/groupsequenceisolation and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-09-30 14:29:48 -0400 (Wed, 30 Sep 2009)
New Revision: 17593
Modified:
beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementTest.java
beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequenceisolation/GroupSequenceIsolationTest.java
Log:
removed some @SpecAssrtion mappings
Modified: beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementTest.java
===================================================================
--- beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementTest.java 2009-09-30 18:17:06 UTC (rev 17592)
+++ beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementTest.java 2009-09-30 18:29:48 UTC (rev 17593)
@@ -136,9 +136,9 @@
}
@Test(enabled = false)
- @SpecAssertion(section = "3.1",
- id = "b",
- note = "The spec is not clear about whether validation of static fields/properties should just be ignored or an exception should be thrown.")
+// @SpecAssertion(section = "3.1",
+// id = "b",
+// note = "The spec is not clear about whether validation of static fields/properties should just be ignored or an exception should be thrown.")
public void testIgnoreStaticFieldsAndProperties() {
StaticFieldsAndProperties entity = new StaticFieldsAndProperties();
Modified: beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequenceisolation/GroupSequenceIsolationTest.java
===================================================================
--- beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequenceisolation/GroupSequenceIsolationTest.java 2009-09-30 18:17:06 UTC (rev 17592)
+++ beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequenceisolation/GroupSequenceIsolationTest.java 2009-09-30 18:29:48 UTC (rev 17593)
@@ -46,7 +46,6 @@
@Test
@SpecAssertions({
@SpecAssertion(section = "3.4.3", id = "a"),
- @SpecAssertion(section = "3.4.3", id = "b"),
@SpecAssertion(section = "3.4.3", id = "c"),
@SpecAssertion(section = "3.4.5", id = "a")
})
@@ -84,7 +83,6 @@
@Test
@SpecAssertions({
@SpecAssertion(section = "3.4.3", id = "a"),
- @SpecAssertion(section = "3.4.3", id = "b"),
@SpecAssertion(section = "3.4.3", id = "c"),
@SpecAssertion(section = "3.4.5", id = "a")
})
15 years, 2 months