[hibernate-commits] Hibernate SVN: r17012 - beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext and 1 other directories.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Tue Jul 7 09:05:38 EDT 2009
Author: epbernard
Date: 2009-07-07 09:05:37 -0400 (Tue, 07 Jul 2009)
New Revision: 17012
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/PathBuilder.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorContextImpl.java
Log:
improve slightly CVC.ErrorBuilder based on PathBuilder's experience
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-07-07 12:02:51 UTC (rev 17011)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-07-07 13:05:37 UTC (rev 17012)
@@ -101,12 +101,15 @@
*/
interface ErrorBuilder {
/**
- * Add a subNode to the path the error will be associated to
+ * Add a subNode to the path the error will be associated to.
*
- * @param name property
- * @return a builder representing the first level node
+ * <code>name</code> describes a single property. In particular,
+ * dot (.) are not allowed.
+ *
+ * @param name property name
+ * @return a builder representing node <code>name</code>
*/
- NodeBuilder inSubNode(String name);
+ NodeBuilderDefinedContext addSubNode(String name);
/**
* Add the new error report to be generated if the
@@ -119,24 +122,28 @@
ConstraintValidatorContext addError();
/**
- * Represent asubnode whose context is known
+ * Represent a subnode whose context is known
* (ie index, key and isInIterable)
*/
- interface NodeBuilder {
+ interface NodeBuilderDefinedContext {
+
/**
- * Add a subNode to the path the error will be associated to
+ * Add a subNode to the path the error will be associated to.
*
- * @param name property
+ * <code>name</code> describes a single property. In particular,
+ * dot (.) are not allowed.
+ *
+ * @param name property <code>name</code>
* @return a builder representing this node
*/
- InIterableNodeBuilder inSubNode(String name);
+ NodeBuilderCustomizableContext addSubNode(String name);
/**
* Add the new error report to be generated if the
* constraint validator mark the value as invalid.
* Methods of the ErrorBuilder instance this object comes
* from and the error builder nested
- * objects returns IllegalStateException from now on.
+ * objects returns IllegalStateException after this call.
*
* @return ConstraintValidatorContext instance the ErrorBuilder comes from
*/
@@ -147,27 +154,32 @@
* Represent a subnode whose context is
* configurable (ie index, key and isInIterable)
*/
- interface InIterableNodeBuilder {
+ interface NodeBuilderCustomizableContext {
+
/**
* Mark the node as being in an Iterable or a Map
+ *
* @return a builder representing iterable details
*/
- InIterablePropertiesBuilder inIterable();
+ NodeContextBuilder inIterable();
/**
- * Add a subNode to the path the error will be associated to
+ * Add a subNode to the path the error will be associated to.
*
- * @param name property
+ * <code>name</code> describes a single property. In particular,
+ * dot (.) are not allowed.
+ *
+ * @param name property <code>name</code>
* @return a builder representing this node
*/
- InIterableNodeBuilder inSubNode(String name);
+ NodeBuilderCustomizableContext addSubNode(String name);
/**
* Add the new error report to be generated if the
* constraint validator mark the value as invalid.
* Methods of the ErrorBuilder instance this object comes
* from and the error builder nested
- * objects returns IllegalStateException from now on.
+ * objects returns IllegalStateException after this call.
*
* @return ConstraintValidatorContext instance the ErrorBuilder comes from
*/
@@ -175,19 +187,20 @@
}
/**
- * Represent choices for a node which is
+ * Represent refinement choices for a node which is
* in an Iterator or Map.
* If the iterator is an indexed collection or a map,
* the index or the key should be set.
*/
- interface InIterablePropertiesBuilder {
+ interface NodeContextBuilder {
+
/**
* Define the key the object is into the Map
*
* @param key map key
* @return a builder representing the current node
*/
- NodeBuilder atKey(Object key);
+ NodeBuilderDefinedContext atKey(Object key);
/**
* Define the index the object is into the List or array
@@ -195,22 +208,25 @@
* @param index index
* @return a builder representing the current node
*/
- NodeBuilder atIndex(Integer index);
+ NodeBuilderDefinedContext atIndex(Integer index);
/**
- * Add a subNode to the path the error will be associated to
+ * Add a subNode to the path the error will be associated to.
*
- * @param name property
+ * <code>name</code> describes a single property. In particular,
+ * dot (.) are not allowed.
+ *
+ * @param name property <code>name</code>
* @return a builder representing this node
*/
- InIterableNodeBuilder inSubNode(String name);
+ NodeBuilderCustomizableContext addSubNode(String name);
/**
* Add the new error report to be generated if the
* constraint validator mark the value as invalid.
* Methods of the ErrorBuilder instance this object comes
* from and the error builder nested
- * objects returns IllegalStateException from now on.
+ * objects returns IllegalStateException after this call.
*
* @return ConstraintValidatorContext instance the ErrorBuilder comes from
*/
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/PathBuilder.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/PathBuilder.java 2009-07-07 12:02:51 UTC (rev 17011)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/PathBuilder.java 2009-07-07 13:05:37 UTC (rev 17012)
@@ -37,23 +37,24 @@
* @param name property
* @return a builder representing this node
*/
- PathBuilder.NodeBuilderWithDefinedContext addSubNode(String name);
+ NodeBuilderDefinedContext addSubNode(String name);
/**
* Represent a node whose context is known
* (ie index, key and isInIterable)
*/
- interface NodeBuilderWithDefinedContext {
+ interface NodeBuilderDefinedContext {
+
/**
* Add a subNode to the path.
*
- * name describes a single property. In particular,
+ * <code>name</code> describes a single property. In particular,
* dot (.) are not allowed.
*
- * @param name property
- * @return a builder representing this node
+ * @param name property <code>name</code>
+ * @return @return a builder representing node <code>name</code>
*/
- NodeBuilderWithCustomizableContext addSubNode(String name);
+ NodeBuilderCustomizableContext addSubNode(String name);
/**
* Return a Path object whose state is represented by
@@ -70,7 +71,8 @@
* Represent a subnode whose context is
* configurable (ie index, key and isInIterable)
*/
- interface NodeBuilderWithCustomizableContext {
+ interface NodeBuilderCustomizableContext {
+
/**
* Mark the node as being in an Iterable or a Map
* @return a builder representing iterable details
@@ -80,13 +82,13 @@
/**
* Add a subNode to the path.
*
- * name describes a single property. In particular,
+ * <code>name</code> describes a single property. In particular,
* dot (.) are not allowed.
*
- * @param name property
+ * @param name property <code>name</code>
* @return a builder representing this node
*/
- NodeBuilderWithCustomizableContext addSubNode(String name);
+ NodeBuilderCustomizableContext addSubNode(String name);
/**
* Return a Path object whose state is represented by
@@ -106,13 +108,14 @@
* the index or the key should be set.
*/
interface NodeContextBuilder {
+
/**
* Define the key the object is into the Map
*
* @param key map key
* @return a builder representing the current node
*/
- NodeBuilderWithDefinedContext atKey(Object key);
+ NodeBuilderDefinedContext atKey(Object key);
/**
* Define the index the object is into the List or array
@@ -120,18 +123,18 @@
* @param index index
* @return a builder representing the current node
*/
- NodeBuilderWithDefinedContext atIndex(Integer index);
+ NodeBuilderDefinedContext atIndex(Integer index);
/**
* Add a subNode to the path.
*
- * name describes a single property. In particular,
+ * <code>name</code> describes a single property. In particular,
* dot (.) are not allowed.
*
- * @param name property
+ * @param name property <code>name</code>
* @return a builder representing this node
*/
- NodeBuilderWithCustomizableContext addSubNode(String name);
+ NodeBuilderCustomizableContext addSubNode(String name);
/**
* Return a Path object whose state is represented by
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java 2009-07-07 12:02:51 UTC (rev 17011)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java 2009-07-07 13:05:37 UTC (rev 17012)
@@ -42,7 +42,7 @@
if ( errorMessages != null ) {
for ( Map.Entry<String, String> entry : errorMessages.entrySet() ) {
constraintValidatorContext.buildErrorWithMessageTemplate( entry.getKey() )
- .inSubNode( entry.getValue() ).addError();
+ .addSubNode( entry.getValue() ).addError();
}
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorContextImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorContextImpl.java 2009-07-07 12:02:51 UTC (rev 17011)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorContextImpl.java 2009-07-07 13:05:37 UTC (rev 17012)
@@ -96,7 +96,7 @@
propertyPath = path;
}
- public NodeBuilder inSubNode(String name) {
+ public NodeBuilderDefinedContext addSubNode(String name) {
PathImpl path = PathImpl.createNewRootPath();
path.addNode( new NodeImpl( name ) );
return new NodeBuilderImpl( messageTemplate, path );
@@ -108,7 +108,7 @@
}
}
- class NodeBuilderImpl implements ErrorBuilder.NodeBuilder {
+ class NodeBuilderImpl implements ErrorBuilder.NodeBuilderDefinedContext {
String messageTemplate;
PathImpl propertyPath;
@@ -117,7 +117,7 @@
propertyPath = path;
}
- public ErrorBuilder.InIterableNodeBuilder inSubNode(String name) {
+ public ErrorBuilder.NodeBuilderCustomizableContext addSubNode(String name) {
NodeImpl node = new NodeImpl( name );
propertyPath.addNode( node );
return new InIterableNodeBuilderImpl( messageTemplate, propertyPath );
@@ -129,7 +129,7 @@
}
}
- class InIterableNodeBuilderImpl implements ErrorBuilder.InIterableNodeBuilder {
+ class InIterableNodeBuilderImpl implements ErrorBuilder.NodeBuilderCustomizableContext {
String messageTemplate;
PathImpl propertyPath;
@@ -138,11 +138,11 @@
propertyPath = path;
}
- public ErrorBuilder.InIterablePropertiesBuilder inIterable() {
+ public ErrorBuilder.NodeContextBuilder inIterable() {
return new InIterablePropertiesBuilderImpl( messageTemplate, propertyPath );
}
- public ErrorBuilder.InIterableNodeBuilder inSubNode(String name) {
+ public ErrorBuilder.NodeBuilderCustomizableContext addSubNode(String name) {
Path.Node node = new NodeImpl( name );
propertyPath.addNode( node );
return this;
@@ -154,7 +154,7 @@
}
}
- class InIterablePropertiesBuilderImpl implements ErrorBuilder.InIterablePropertiesBuilder {
+ class InIterablePropertiesBuilderImpl implements ErrorBuilder.NodeContextBuilder {
String messageTemplate;
PathImpl propertyPath;
@@ -164,17 +164,17 @@
propertyPath.getLeafNode().setInIterable( true );
}
- public ErrorBuilder.NodeBuilder atKey(Object key) {
+ public ErrorBuilder.NodeBuilderDefinedContext atKey(Object key) {
propertyPath.getLeafNode().setKey( key );
return new NodeBuilderImpl( messageTemplate, propertyPath );
}
- public ErrorBuilder.NodeBuilder atIndex(Integer index) {
+ public ErrorBuilder.NodeBuilderDefinedContext atIndex(Integer index) {
propertyPath.getLeafNode().setIndex( index );
return new NodeBuilderImpl( messageTemplate, propertyPath );
}
- public ErrorBuilder.InIterableNodeBuilder inSubNode(String name) {
+ public ErrorBuilder.NodeBuilderCustomizableContext addSubNode(String name) {
Path.Node node = new NodeImpl( name );
propertyPath.addNode( node );
return new InIterableNodeBuilderImpl( messageTemplate, propertyPath );
More information about the hibernate-commits
mailing list