Author: epbernard
Date: 2008-10-31 14:06:19 -0400 (Fri, 31 Oct 2008)
New Revision: 15475
Added:
validator/trunk/validation-api/src/main/java/javax/validation/ReportAsViolationFromComposingConstraint.java
Removed:
validator/trunk/validation-api/src/main/java/javax/validation/InvalidConstraint.java
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/impl/ConstraintDescriptorImpl.java
validator/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java
validator/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java
validator/trunk/validation-api/src/main/java/javax/validation/Context.java
validator/trunk/validation-api/src/main/java/javax/validation/Validator.java
Log:
BVAL-40 rename ConstraintViolation
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/impl/ConstraintDescriptorImpl.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/impl/ConstraintDescriptorImpl.java 2008-10-31
17:29:01 UTC (rev 15474)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/impl/ConstraintDescriptorImpl.java 2008-10-31
18:06:19 UTC (rev 15475)
@@ -28,7 +28,7 @@
import java.util.Set;
import javax.validation.Constraint;
import javax.validation.ConstraintDescriptor;
-import javax.validation.ReportAsSingleInvalidConstraint;
+import javax.validation.ReportAsViolationFromComposingConstraint;
import javax.validation.ValidationException;
/**
@@ -55,7 +55,7 @@
this.constraintImplementation = validator;
this.parameters = getAnnotationParameters( annotation );
this.isReportAsSingleInvalidConstraint =
annotation.annotationType().isAnnotationPresent(
- ReportAsSingleInvalidConstraint.class
+ ReportAsViolationFromComposingConstraint.class
);
this.constraintClass = constraintClass;
}
@@ -114,7 +114,7 @@
/**
* {@inheritDoc}
*/
- public boolean isReportAsSingleInvalidConstraint() {
+ public boolean ReportAsViolationFromComposingConstraint() {
return isReportAsSingleInvalidConstraint;
}
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-31
17:29:01 UTC (rev 15474)
+++
validator/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java 2008-10-31
18:06:19 UTC (rev 15475)
@@ -70,5 +70,5 @@
/**
* @return true if the constraint is annotated with @ReportAsSingleInvalidConstraint
*/
- boolean isReportAsSingleInvalidConstraint();
+ boolean ReportAsViolationFromComposingConstraint();
}
Modified:
validator/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java
===================================================================
---
validator/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java 2008-10-31
17:29:01 UTC (rev 15474)
+++
validator/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java 2008-10-31
18:06:19 UTC (rev 15475)
@@ -20,7 +20,8 @@
import java.util.Set;
/**
- * Describe a constraint validation defect.
+ * Describe a constraint violation. This object describe the error context as
+ * well as the message describing the violation.
*
* @author Emmanuel Bernard
* @todo add pointers to the metadata?
Modified: validator/trunk/validation-api/src/main/java/javax/validation/Context.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/Context.java 2008-10-31
17:29:01 UTC (rev 15474)
+++ validator/trunk/validation-api/src/main/java/javax/validation/Context.java 2008-10-31
18:06:19 UTC (rev 15475)
@@ -7,8 +7,8 @@
*/
public interface Context {
/**
- * Disable default error message and default InvalidConstraint object generation.
- * Useful to set a different error message or generate an InvalidConstraint based on
+ * Disable default error message and default ConstraintViolation object generation.
+ * Useful to set a different error message or generate an ConstraintViolation based on
* a different property
*
* @see #addError(String)
@@ -25,13 +25,13 @@
/**
* Add a new unexpanded error message.
* <p/>
- * If isValid returns false, an InvalidConstraint object will be built per error
message
+ * If isValid returns false, a ConstraintViolation object will be built per error
message
* including the default one unless #disableDefaultErrorMEssage() has been called.
* <p/>
- * Aside from the error message, InvalidConstraint objects generated from such a call
+ * Aside from the error message, ConstraintViolation objects generated from such a call
* contains the same contextual information (root bean, path and so on)
* <p/>
- * This method can be called multiple time. One InvalidConstraint instance per call is
created.
+ * This method can be called multiple time. One ConstraintViolation instance per call is
created.
*
* @param message new unexpanded error message
*/
@@ -40,13 +40,13 @@
/**
* Add a new unexpanded error message to a given sub property.
* <p/>
- * If isValid returns false, an InvalidConstraint object will be built per error message
including the default one
+ * If isValid returns false, a ConstraintViolation object will be built per error
message including the default one
* if null apply to the current property or the bean the constraint is applied on,
otherwise apply to the <code>property</code> named
* <p/>
* TODO exception or swallowed when bean-level instance is not present?
*
* @param message new unexpanded error message
- * @param property property name the InvalidConstraint is targeting
+ * @param property property name the ConstraintViolation is targeting
*
* @throws ValidationException when the property is not present on the bean level
object
*/
Deleted:
validator/trunk/validation-api/src/main/java/javax/validation/InvalidConstraint.java
===================================================================
---
validator/trunk/validation-api/src/main/java/javax/validation/InvalidConstraint.java 2008-10-31
17:29:01 UTC (rev 15474)
+++
validator/trunk/validation-api/src/main/java/javax/validation/InvalidConstraint.java 2008-10-31
18:06:19 UTC (rev 15475)
@@ -1,73 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package javax.validation;
-
-import java.util.Set;
-
-/**
- * Describe a constraint validation defect.
- *
- * @author Emmanuel Bernard
- * @todo add pointers to the metadata?
- * @todo the rational behind rootBean and propertyPath is to keep the context available
to the user
- */
-public interface InvalidConstraint<T> {
-
- /**
- * @return The error message for this constraint violation.
- */
- String getMessage();
-
- /**
- * @return The root bean being validated.
- */
- T getRootBean();
-
- /**
- * If a bean constraint, the bean instance the constraint is applied on
- * If a property constraint, the bean instance hosting the property the constraint is
applied on
- *
- * @return the leaf bean the constraint is applied on or null if Validator#validateValue
is used
- */
- Object getLeafBean();
-
- /**
- * @return the property path to the value from <code>rootBean</code>
- * <code>null</code> if the value is the
<code>rootBean<code> itself.
- */
- String getPropertyPath();
-
-
- /**
- * @return the bean type being validated.
- */
- Class<T> getBeanClass();
-
- /**
- * @return the value failing to pass the constraint.
- */
- Object getValue();
-
- /**
- * @return the list of groups that the triggered constraint applies on and which also
are
- * within the list of groups requested for validation.
- *
- * TODO: considering removal, if you think it's important, speak up
- */
- Set<String> getGroups();
-}
Copied:
validator/trunk/validation-api/src/main/java/javax/validation/ReportAsViolationFromComposingConstraint.java
(from rev 15465,
validator/trunk/validation-api/src/main/java/javax/validation/ReportAsSingleInvalidConstraint.java)
===================================================================
---
validator/trunk/validation-api/src/main/java/javax/validation/ReportAsViolationFromComposingConstraint.java
(rev 0)
+++
validator/trunk/validation-api/src/main/java/javax/validation/ReportAsViolationFromComposingConstraint.java 2008-10-31
18:06:19 UTC (rev 15475)
@@ -0,0 +1,35 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package javax.validation;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+
+/**
+ * A constraint annotation annotated with this annotation
+ * will return the composed annotation error report if any of the composing annotations
+ * fail. The error reports of each individual composing constraint is ignored.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({ ANNOTATION_TYPE })
+@Retention(RUNTIME)
+public @interface ReportAsViolationFromComposingConstraint {
+}
Property changes on:
validator/trunk/validation-api/src/main/java/javax/validation/ReportAsViolationFromComposingConstraint.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/validation-api/src/main/java/javax/validation/Validator.java
===================================================================
---
validator/trunk/validation-api/src/main/java/javax/validation/Validator.java 2008-10-31
17:29:01 UTC (rev 15474)
+++
validator/trunk/validation-api/src/main/java/javax/validation/Validator.java 2008-10-31
18:06:19 UTC (rev 15475)
@@ -29,44 +29,41 @@
*/
public interface Validator<T> extends Serializable {
/**
- * validate all constraints on object (unless shortcut)
+ * validate all constraints on object
*
* @param object object to validate
- * @param groups group name(s) targeted for validation (default to
<code>default</code>
+ * @param groups group name(s) targeted for validation (default to
<code>default</code>)
*
- * @return array of invalid constrains or an empty array if none.
+ * @return constraint violations or an empty Set if none
*
- * @throws IllegalArgumentException e if object is <code>null</code>.
+ * @throws IllegalArgumentException e if object is null
*/
Set<ConstraintViolation<T>> validate(T object, String... groups);
/**
- * validate all constraints on propertyname property of object (unless shortcut)
- * <p/>
+ * validate all constraints on <code>propertyName</code>
property of object
*
* @param object object to validate
* @param propertyName property to validate
- * @param groups group name(s) targeted for validation (default to
<code>default</code>
+ * @param groups group name(s) targeted for validation (default to
<code>default</code>)
*
- * @return array of invalid constrains or an empty array if none
+ * @return constraint violations or an empty Set if none
*
- * @throws IllegalArgumentException e if object is <code>null</code>.
- * @todo Do we keep this method?
+ * @throws IllegalArgumentException e if object is null
*/
Set<ConstraintViolation<T>> validateProperty(T object, String propertyName,
String... groups);
/**
- * Validates all constraints on propertyname property if the property value is value
(unless shortcut)
+ * validate all constraints on <code>propertyName</code> property
+ * if the property value is <code>value</code>
* <p/>
+ * TODO express limitations of ConstraintViolation in this case
*
* @param propertyName property to validate
* @param value property value to validate
- * @param groups group name(s) targeted for validation (default to
<code>default</code>
+ * @param groups group name(s) targeted for validation (default to
<code>default</code>)
*
- * @return array of invalid constrains or an empty array if none
- *
- * @todo Do we keep this method?
- * @todo express limitations of InvalidConstraint in this case.
+ * @return constraint violations or an empty Set if none
*/
Set<ConstraintViolation<T>> validateValue(String propertyName, Object value,
String... groups);
@@ -85,7 +82,7 @@
* return the property level constraints for a given propertyName
* or null if either the property does not exist or has no constraint
*/
- ElementDescriptor getConstraintsForProperty(String propertyName);
+ ElementDescriptor getConstraintsForProperty(String propertyName);
/**
* return the property names having at least a constraint defined