[hibernate-commits] Hibernate SVN: r15817 - in validator/trunk: hibernate-validator/src/main/java/org/hibernate/validation/engine and 11 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Sun Jan 25 17:35:37 EST 2009


Author: epbernard
Date: 2009-01-25 17:35:36 -0500 (Sun, 25 Jan 2009)
New Revision: 15817

Added:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/LengthConstraintValidator.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmptyConstraintValidator.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullConstraintValidator.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PatternConstraintValidator.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeConstraintValidator.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorContextImpl.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcodeConstraintValidator.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/GermanZipcodeConstraintValidator.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/UKZipcodeConstraintValidator.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoGroupsConstraintValidator.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoMessageConstraintValidator.java
   validator/trunk/validation-api/src/main/java/javax/validation/Constraint.java
   validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java
   validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java
   validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/FineGrainedLengthConstraintValidator.java
   validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/LengthConstraintValidator.java
Removed:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/LengthConstraint.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmptyConstraint.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullConstraint.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PatternConstraint.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeConstraint.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintContextImpl.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcodeConstraint.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/GermanZipcodeConstraint.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/UKZipcodeConstraint.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoGroupsConstraint.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoMessageConstraint.java
   validator/trunk/validation-api/src/main/java/javax/validation/Constraint.java
   validator/trunk/validation-api/src/main/java/javax/validation/ConstraintContext.java
   validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java
   validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/FineGrainedLengthConstraint.java
   validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/LengthConstraint.java
Modified:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/Length.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmpty.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/Pattern.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/impl/ConstraintDescriptorImpl.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/impl/ConstraintFactoryImpl.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java
   validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/BuiltinConstraintDefinitions.properties
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthConstraintTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyConstraintTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotNullConstraintTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternConstraintTest.java
   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/GermanZipcode.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/UKZipcode.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoGroups.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoMessage.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/ValidProperty.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ConstraintCompositionTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java
   validator/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java
   validator/trunk/validation-api/src/main/java/javax/validation/ConstraintFactory.java
   validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/Length.java
Log:
BVAL-91 rename constraint related classes to make them more readable. Check the spec. Applied to the RI as well

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/Length.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/Length.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/Length.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -24,7 +24,7 @@
 import java.lang.annotation.Retention;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import java.lang.annotation.Target;
-import javax.validation.ConstraintValidator;
+import javax.validation.Constraint;
 
 /**
  * Validate that the string is between min and max included
@@ -32,7 +32,7 @@
  * @author Emmanuel Bernard
  */
 @Documented
- at ConstraintValidator(LengthConstraint.class)
+ at Constraint(validatedBy = LengthConstraintValidator.class)
 @Target({ METHOD, FIELD, TYPE })
 @Retention(RUNTIME)
 public @interface Length {

Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/LengthConstraint.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/LengthConstraint.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/LengthConstraint.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -1,50 +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 org.hibernate.validation.constraints;
-
-import javax.validation.Constraint;
-import javax.validation.ConstraintContext;
-
-/**
- * Check that a string's length is between min and max.
- *
- * @author Emmanuel Bernard
- * @author Gavin King
- */
-public class LengthConstraint implements Constraint<Length> {
-	private int min;
-	private int max;
-
-	public void initialize(Length parameters) {
-		min = parameters.min();
-		max = parameters.max();
-	}
-
-	public boolean isValid(Object value, ConstraintContext constraintContext) {
-		if ( value == null ) {
-			return true;
-		}
-		if ( !( value instanceof String ) ) {
-			throw new IllegalArgumentException( "Expected String type." );                                                              
-		}
-		String string = ( String ) value;
-		int length = string.length();
-		return length >= min && length <= max;
-	}
-
-}
\ No newline at end of file

Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/LengthConstraintValidator.java (from rev 15815, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/LengthConstraint.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/LengthConstraintValidator.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/LengthConstraintValidator.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -0,0 +1,50 @@
+// $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 org.hibernate.validation.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * Check that a string's length is between min and max.
+ *
+ * @author Emmanuel Bernard
+ * @author Gavin King
+ */
+public class LengthConstraintValidator implements ConstraintValidator<Length> {
+	private int min;
+	private int max;
+
+	public void initialize(Length parameters) {
+		min = parameters.min();
+		max = parameters.max();
+	}
+
+	public boolean isValid(Object value, ConstraintValidatorContext constraintValidatorContext) {
+		if ( value == null ) {
+			return true;
+		}
+		if ( !( value instanceof String ) ) {
+			throw new IllegalArgumentException( "Expected String type." );                                                              
+		}
+		String string = ( String ) value;
+		int length = string.length();
+		return length >= min && length <= max;
+	}
+
+}
\ No newline at end of file

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmpty.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmpty.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmpty.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -23,13 +23,13 @@
 import java.lang.annotation.Retention;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import java.lang.annotation.Target;
-import javax.validation.ConstraintValidator;
+import javax.validation.Constraint;
 
 /**
  * @author Emmanuel Bernard
  */
 @Documented
- at ConstraintValidator(NotEmptyConstraint.class)
+ at Constraint(validatedBy = NotEmptyConstraintValidator.class)
 @Target({ METHOD, FIELD })
 @Retention(RUNTIME)
 public @interface NotEmpty {

Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmptyConstraint.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmptyConstraint.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmptyConstraint.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -1,43 +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 org.hibernate.validation.constraints;
-
-import javax.validation.Constraint;
-import javax.validation.ConstraintContext;
-
-/**
- * @author Hardy Ferentschik
- * @todo Extend to not only support strings, but also collections and maps. Needs to be specified first though.
- */
-public class NotEmptyConstraint implements Constraint<NotEmpty> {
-
-	public void initialize(NotEmpty parameters) {
-	}
-
-	public boolean isValid(Object object, ConstraintContext constraintContext) {
-		if ( object == null ) {
-			return true;
-		}
-		if ( !( object instanceof String ) ) {
-			throw new IllegalArgumentException( "Expected String type." );
-		}
-		String string = ( String ) object;
-		int length = string.length();
-		return length > 0;
-	}
-}

Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmptyConstraintValidator.java (from rev 15815, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmptyConstraint.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmptyConstraintValidator.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmptyConstraintValidator.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -0,0 +1,43 @@
+// $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 org.hibernate.validation.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+ * @todo Extend to not only support strings, but also collections and maps. Needs to be specified first though.
+ */
+public class NotEmptyConstraintValidator implements ConstraintValidator<NotEmpty> {
+
+	public void initialize(NotEmpty parameters) {
+	}
+
+	public boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext) {
+		if ( object == null ) {
+			return true;
+		}
+		if ( !( object instanceof String ) ) {
+			throw new IllegalArgumentException( "Expected String type." );
+		}
+		String string = ( String ) object;
+		int length = string.length();
+		return length > 0;
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmptyConstraintValidator.java
___________________________________________________________________
Name: svn:keywords
   + Id

Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullConstraint.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullConstraint.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullConstraint.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -1,37 +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 org.hibernate.validation.constraints;
-
-import javax.validation.Constraint;
-import javax.validation.ConstraintContext;
-import javax.validation.constraints.NotNull;
-
-/**
- * Validate that the object is not <code>null</code>.
- *
- * @author Emmanuel Bernard
- */
-public class NotNullConstraint implements Constraint<NotNull> {
-
-	public void initialize(NotNull parameters) {
-	}
-
-	public boolean isValid(Object object, ConstraintContext constraintContext) {
-		return object != null;
-	}
-}

Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullConstraintValidator.java (from rev 15815, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullConstraint.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullConstraintValidator.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullConstraintValidator.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -0,0 +1,37 @@
+// $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 org.hibernate.validation.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.NotNull;
+
+/**
+ * Validate that the object is not <code>null</code>.
+ *
+ * @author Emmanuel Bernard
+ */
+public class NotNullConstraintValidator implements ConstraintValidator<NotNull> {
+
+	public void initialize(NotNull parameters) {
+	}
+
+	public boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext) {
+		return object != null;
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullConstraintValidator.java
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/Pattern.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/Pattern.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/Pattern.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -23,13 +23,13 @@
 import java.lang.annotation.Retention;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import java.lang.annotation.Target;
-import javax.validation.ConstraintValidator;
+import javax.validation.Constraint;
 
 /**
  * @author Hardy Ferentschik
  */
 @Documented
- at ConstraintValidator(PatternConstraint.class)
+ at Constraint(validatedBy = PatternConstraintValidator.class)
 @Target({ METHOD, FIELD })
 @Retention(RUNTIME)
 public @interface Pattern {

Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PatternConstraint.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PatternConstraint.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PatternConstraint.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -1,49 +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 org.hibernate.validation.constraints;
-
-import java.util.regex.Matcher;
-import javax.validation.Constraint;
-import javax.validation.ConstraintContext;
-
-/**
- * @author Hardy Ferentschik
- */
-public class PatternConstraint implements Constraint<Pattern> {
-
-	private java.util.regex.Pattern pattern;
-
-	public void initialize(Pattern parameters) {
-		pattern = java.util.regex.Pattern.compile(
-				parameters.regex(),
-				parameters.flags()
-		);
-	}
-
-	public boolean isValid(Object value, ConstraintContext constraintContext) {
-		if ( value == null ) {
-			return true;
-		}
-		if ( !( value instanceof String ) ) {
-			throw new IllegalArgumentException( "Expected String type." );
-		}
-		String string = ( String ) value;
-		Matcher m = pattern.matcher( string );
-		return m.matches();
-	}
-}

Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PatternConstraintValidator.java (from rev 15815, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PatternConstraint.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PatternConstraintValidator.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PatternConstraintValidator.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -0,0 +1,49 @@
+// $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 org.hibernate.validation.constraints;
+
+import java.util.regex.Matcher;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class PatternConstraintValidator implements ConstraintValidator<Pattern> {
+
+	private java.util.regex.Pattern pattern;
+
+	public void initialize(Pattern parameters) {
+		pattern = java.util.regex.Pattern.compile(
+				parameters.regex(),
+				parameters.flags()
+		);
+	}
+
+	public boolean isValid(Object value, ConstraintValidatorContext constraintValidatorContext) {
+		if ( value == null ) {
+			return true;
+		}
+		if ( !( value instanceof String ) ) {
+			throw new IllegalArgumentException( "Expected String type." );
+		}
+		String string = ( String ) value;
+		Matcher m = pattern.matcher( string );
+		return m.matches();
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PatternConstraintValidator.java
___________________________________________________________________
Name: svn:keywords
   + Id

Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeConstraint.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeConstraint.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeConstraint.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -1,67 +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 org.hibernate.validation.constraints;
-
-import java.util.Collection;
-import java.lang.reflect.Array;
-import javax.validation.Constraint;
-import javax.validation.ConstraintContext;
-import javax.validation.constraints.Size;
-
-/**
- * Check that a string's length is between min and max.
- *
- * @author Emmanuel Bernard
- * @author Gavin King
- */
-public class SizeConstraint implements Constraint<Size> {
-	private int min;
-	private int max;
-
-	public void initialize(Size parameters) {
-		min = parameters.min();
-		max = parameters.max();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public boolean isValid(Object value, ConstraintContext constraintContext) {
-		if ( value == null ) {
-			return true;
-		}
-
-		int size;
-		if ( value instanceof String ) {
-			String string = ( String ) value;
-			size = string.length();
-
-		}
-		else if ( value instanceof Collection ) {
-			Collection collection = ( Collection ) value;
-			size = collection.size();
-		}
-		else if ( value instanceof Array ) {
-			size = Array.getLength( value );
-		}
-		else {
-			throw new IllegalArgumentException( "Expected String type." );
-		}
-		return size >= min && size <= max;
-	}
-}

Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeConstraintValidator.java (from rev 15815, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeConstraint.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeConstraintValidator.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeConstraintValidator.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -0,0 +1,67 @@
+// $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 org.hibernate.validation.constraints;
+
+import java.util.Collection;
+import java.lang.reflect.Array;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Size;
+
+/**
+ * Check that a string's length is between min and max.
+ *
+ * @author Emmanuel Bernard
+ * @author Gavin King
+ */
+public class SizeConstraintValidator implements ConstraintValidator<Size> {
+	private int min;
+	private int max;
+
+	public void initialize(Size parameters) {
+		min = parameters.min();
+		max = parameters.max();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public boolean isValid(Object value, ConstraintValidatorContext constraintValidatorContext) {
+		if ( value == null ) {
+			return true;
+		}
+
+		int size;
+		if ( value instanceof String ) {
+			String string = ( String ) value;
+			size = string.length();
+
+		}
+		else if ( value instanceof Collection ) {
+			Collection collection = ( Collection ) value;
+			size = collection.size();
+		}
+		else if ( value instanceof Array ) {
+			size = Array.getLength( value );
+		}
+		else {
+			throw new IllegalArgumentException( "Expected String type." );
+		}
+		return size >= min && size <= max;
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeConstraintValidator.java
___________________________________________________________________
Name: svn:keywords
   + Id

Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintContextImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintContextImpl.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintContextImpl.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -1,84 +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 org.hibernate.validation.engine;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import javax.validation.ConstraintContext;
-import javax.validation.ConstraintDescriptor;
-
-/**
- * @author Emmanuel Bernard
- */
-public class ConstraintContextImpl implements ConstraintContext {
-	private final ConstraintDescriptor constraintDescriptor;
-	private final List<ErrorMessage> errorMessages;
-	private boolean defaultDisabled;
-
-	public ConstraintContextImpl(ConstraintDescriptor constraintDescriptor) {
-		this.constraintDescriptor = constraintDescriptor;
-		this.errorMessages = new ArrayList<ErrorMessage>(3);
-	}
-
-	public void disableDefaultError() {
-		defaultDisabled = true;
-	}
-
-	public String getDefaultErrorMessage() {
-		return ( String ) constraintDescriptor.getParameters().get("message");
-	}
-
-	public void addError(String message) {
-		//FIXME get the default property if property-level
-		errorMessages.add( new ErrorMessage( message, null ) );
-	}
-
-	public void addError(String message, String property) {
-		//FIXME: make sure the property is valid
-		errorMessages.add( new ErrorMessage( message, property ) );
-	}
-
-	public List<ErrorMessage> getErrorMessages() {
-		List<ErrorMessage> returnedErrorMessages = new ArrayList<ErrorMessage>( errorMessages.size() + 1 );
-		Collections.copy( returnedErrorMessages, errorMessages );
-		if ( ! defaultDisabled ) {
-			//FIXME get the default property if property-level
-			returnedErrorMessages.add( new ErrorMessage( getDefaultErrorMessage(), null) );
-		}
-		return returnedErrorMessages;
-	}
-
-	public static class ErrorMessage {
-		private final String message;
-		private final String property;
-
-		private ErrorMessage(String message, String property) {
-			this.message = message;
-			this.property = property;
-		}
-
-		public String getMessage() {
-			return message;
-		}
-
-		public String getProperty() {
-			return property;
-		}
-	}
-}

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -19,7 +19,7 @@
 
 import java.util.List;
 import java.util.ArrayList;
-import javax.validation.Constraint;
+import javax.validation.ConstraintValidator;
 import javax.validation.ConstraintDescriptor;
 import javax.validation.ValidationException;
 import javax.validation.ConstraintFactory;
@@ -42,7 +42,7 @@
 
 	private final ConstraintTree parent;
 	private final List<ConstraintTree> children;
-	private Constraint constraint;
+	private ConstraintValidator constraintValidator;
 	private final ConstraintDescriptor descriptor;
 	private final ConstraintFactory constraintFactory;
 	private final MessageInterpolator messageInterpolator;
@@ -56,7 +56,7 @@
 		this.descriptor = descriptor;
 		this.constraintFactory = constraintFactory;
 		this.messageInterpolator = messageInterpolator;
-		this.constraint = getConstraint( descriptor );
+		this.constraintValidator = getConstraint( descriptor );
 		children = new ArrayList<ConstraintTree>( descriptor.getComposingConstraints().size() );
 
 		for ( ConstraintDescriptor composingDescriptor : descriptor.getComposingConstraints() ) {
@@ -83,8 +83,8 @@
 		return children.size() > 0;
 	}
 
-	public Constraint getConstraint() {
-		return constraint;
+	public ConstraintValidator getConstraint() {
+		return constraintValidator;
 	}
 
 	public ConstraintDescriptor getDescriptor() {
@@ -97,12 +97,12 @@
 		}
 
 		final Object leafBeanInstance = validationContext.peekValidatedObject();
-		ConstraintContextImpl constraintContext = new ConstraintContextImpl( descriptor );
+		ConstraintValidatorContextImpl constraintContext = new ConstraintValidatorContextImpl( descriptor );
 		if ( log.isTraceEnabled() ) {
 			log.trace( "Validating value {} against constraint defined by {}", value, descriptor );
 		}
-		if ( !constraint.isValid( value, constraintContext ) ) {
-			for ( ConstraintContextImpl.ErrorMessage error : constraintContext.getErrorMessages() ) {
+		if ( !constraintValidator.isValid( value, constraintContext ) ) {
+			for ( ConstraintValidatorContextImpl.ErrorMessage error : constraintContext.getErrorMessages() ) {
 				final String message = error.getMessage();
 				createConstraintViolation( value, beanClass, validationContext, leafBeanInstance, message, descriptor );
 			}
@@ -143,22 +143,22 @@
 	}
 
 	@SuppressWarnings("unchecked")
-	private Constraint getConstraint(ConstraintDescriptor descriptor) {
-		Constraint constraint;
+	private ConstraintValidator getConstraint(ConstraintDescriptor descriptor) {
+		ConstraintValidator constraintValidator;
 		try {
 			//unchecked
-			constraint = constraintFactory.getInstance( descriptor.getConstraintClass() );
+			constraintValidator = constraintFactory.getInstance( descriptor.getConstraintValidatorClass() );
 		}
 		catch ( RuntimeException e ) {
-			throw new ValidationException( "Unable to instantiate " + descriptor.getConstraintClass(), e );
+			throw new ValidationException( "Unable to instantiate " + descriptor.getConstraintValidatorClass(), e );
 		}
 
 		try {
-			constraint.initialize( descriptor.getAnnotation() );
+			constraintValidator.initialize( descriptor.getAnnotation() );
 		}
 		catch ( RuntimeException e ) {
-			throw new ValidationException( "Unable to intialize " + constraint.getClass().getName(), e );
+			throw new ValidationException( "Unable to intialize " + constraintValidator.getClass().getName(), e );
 		}
-		return constraint;
+		return constraintValidator;
 	}
 }

Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorContextImpl.java (from rev 15815, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintContextImpl.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorContextImpl.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorContextImpl.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -0,0 +1,84 @@
+// $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 org.hibernate.validation.engine;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.ConstraintDescriptor;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class ConstraintValidatorContextImpl implements ConstraintValidatorContext {
+	private final ConstraintDescriptor constraintDescriptor;
+	private final List<ErrorMessage> errorMessages;
+	private boolean defaultDisabled;
+
+	public ConstraintValidatorContextImpl(ConstraintDescriptor constraintDescriptor) {
+		this.constraintDescriptor = constraintDescriptor;
+		this.errorMessages = new ArrayList<ErrorMessage>(3);
+	}
+
+	public void disableDefaultError() {
+		defaultDisabled = true;
+	}
+
+	public String getDefaultErrorMessage() {
+		return ( String ) constraintDescriptor.getParameters().get("message");
+	}
+
+	public void addError(String message) {
+		//FIXME get the default property if property-level
+		errorMessages.add( new ErrorMessage( message, null ) );
+	}
+
+	public void addError(String message, String property) {
+		//FIXME: make sure the property is valid
+		errorMessages.add( new ErrorMessage( message, property ) );
+	}
+
+	public List<ErrorMessage> getErrorMessages() {
+		List<ErrorMessage> returnedErrorMessages = new ArrayList<ErrorMessage>( errorMessages.size() + 1 );
+		Collections.copy( returnedErrorMessages, errorMessages );
+		if ( ! defaultDisabled ) {
+			//FIXME get the default property if property-level
+			returnedErrorMessages.add( new ErrorMessage( getDefaultErrorMessage(), null) );
+		}
+		return returnedErrorMessages;
+	}
+
+	public static class ErrorMessage {
+		private final String message;
+		private final String property;
+
+		private ErrorMessage(String message, String property) {
+			this.message = message;
+			this.property = property;
+		}
+
+		public String getMessage() {
+			return message;
+		}
+
+		public String getProperty() {
+			return property;
+		}
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorContextImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id

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	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/impl/ConstraintDescriptorImpl.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -27,9 +27,9 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.List;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintDescriptor;
 import javax.validation.Constraint;
-import javax.validation.ConstraintDescriptor;
-import javax.validation.ConstraintValidator;
 import javax.validation.OverridesParameter;
 import javax.validation.OverridesParameters;
 import javax.validation.ReportAsViolationFromCompositeConstraint;
@@ -55,7 +55,7 @@
 	private static final int OVERRIDES_PARAMETER_DEFAULT_INDEX = -1;
 
 	private final Annotation annotation;
-	private final Class<? extends Constraint> constraintClass;
+	private final Class<? extends ConstraintValidator> constraintClass;
 	private final Set<Class<?>> groups;
 	private final Map<String, Object> parameters;
 	private final Set<ConstraintDescriptor> composingConstraints = new HashSet<ConstraintDescriptor>();
@@ -84,9 +84,9 @@
 			this.constraintClass = ReflectionHelper.getBuiltInConstraint( annotation );
 		}
 		else {
-			ConstraintValidator constraintValidator = annotation.annotationType()
-					.getAnnotation( ConstraintValidator.class );
-			this.constraintClass = constraintValidator.value();
+			Constraint constraint = annotation.annotationType()
+					.getAnnotation( Constraint.class );
+			this.constraintClass = constraint.validatedBy();
 		}
 
 		parseOverrideParameters();
@@ -110,7 +110,7 @@
 	/**
 	 * {@inheritDoc}
 	 */
-	public Class<? extends Constraint> getConstraintClass() {
+	public Class<? extends ConstraintValidator> getConstraintValidatorClass() {
 		return constraintClass;
 	}
 

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/impl/ConstraintFactoryImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/impl/ConstraintFactoryImpl.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/impl/ConstraintFactoryImpl.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -17,7 +17,7 @@
 */
 package org.hibernate.validation.impl;
 
-import javax.validation.Constraint;
+import javax.validation.ConstraintValidator;
 import javax.validation.ConstraintFactory;
 import javax.validation.ValidationException;
 
@@ -31,7 +31,7 @@
 	/**
 	 * {@inheritDoc}
 	 */
-	public <T extends Constraint> T getInstance(Class<T> key) {
+	public <T extends ConstraintValidator> T getInstance(Class<T> key) {
 		try {
 			return key.newInstance();
 		}

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -38,8 +38,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import javax.validation.ConstraintValidator;
 import javax.validation.Constraint;
-import javax.validation.ConstraintValidator;
 import javax.validation.ValidationException;
 
 import org.slf4j.Logger;
@@ -71,7 +71,7 @@
 	}
 
 
-	public static Class<? extends Constraint> getBuiltInConstraint(Annotation annotation) {
+	public static Class<? extends ConstraintValidator> getBuiltInConstraint(Annotation annotation) {
 		Class constraint = null;
 		String annotationType = annotation.annotationType().getName();
 		if ( builtInConstraints.containsKey( annotationType ) ) {
@@ -122,9 +122,9 @@
 	 */
 	public static boolean isConstraintAnnotation(Annotation annotation) {
 
-		ConstraintValidator constraintValidator = annotation.annotationType()
-				.getAnnotation( ConstraintValidator.class );
-		if ( constraintValidator == null ) {
+		Constraint constraint = annotation.annotationType()
+				.getAnnotation( Constraint.class );
+		if ( constraint == null ) {
 			return false;
 		}
 
@@ -132,7 +132,7 @@
 			getAnnotationParameter( annotation, "message", String.class );
 		}
 		catch ( Exception e ) {
-			String msg = annotation.annotationType().getName() + " contains ConstraintValidator annotation, but does " +
+			String msg = annotation.annotationType().getName() + " contains Constraint annotation, but does " +
 					"not contain a message parameter. Annotation is getting ignored.";
 			log.warn( msg );
 			return false;
@@ -142,7 +142,7 @@
 			getAnnotationParameter( annotation, "groups", Class[].class );
 		}
 		catch ( Exception e ) {
-			String msg = annotation.annotationType().getName() + " contains ConstraintValidator annotation, but does " +
+			String msg = annotation.annotationType().getName() + " contains Constraint annotation, but does " +
 					"not contain a groups parameter. Annotation is getting ignored.";
 			log.warn( msg );
 			return false;

Modified: validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/BuiltinConstraintDefinitions.properties
===================================================================
--- validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/BuiltinConstraintDefinitions.properties	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/BuiltinConstraintDefinitions.properties	2009-01-25 22:35:36 UTC (rev 15817)
@@ -1,3 +1,3 @@
 # $Id$
-javax.validation.constraints.NotNull=org.hibernate.validation.constraints.NotNullConstraint
-javax.validation.constraints.Size=org.hibernate.validation.constraints.SizeConstraint
\ No newline at end of file
+javax.validation.constraints.NotNull=org.hibernate.validation.constraints.NotNullConstraintValidator
+javax.validation.constraints.Size=org.hibernate.validation.constraints.SizeConstraintValidator
\ No newline at end of file

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -21,7 +21,7 @@
 import java.util.List;
 import java.util.Set;
 import java.util.Locale;
-import javax.validation.Constraint;
+import javax.validation.ConstraintValidator;
 import javax.validation.ConstraintDescriptor;
 import javax.validation.ConstraintFactory;
 import javax.validation.ConstraintViolation;
@@ -32,7 +32,7 @@
 import javax.validation.Validator;
 import javax.validation.ValidatorFactoryBuilder;
 import javax.validation.ValidatorFactory;
-import javax.validation.ConstraintContext;
+import javax.validation.ConstraintValidatorContext;
 import javax.validation.bootstrap.SpecializedBuilderFactory;
 import javax.validation.spi.ValidationProvider;
 
@@ -43,7 +43,7 @@
 import org.junit.Test;
 
 import org.hibernate.validation.HibernateValidatorFactoryBuilder;
-import org.hibernate.validation.constraints.NotNullConstraint;
+import org.hibernate.validation.constraints.NotNullConstraintValidator;
 import org.hibernate.validation.eg.Customer;
 import org.hibernate.validation.impl.ConstraintFactoryImpl;
 import org.hibernate.validation.impl.ValidatorFactoryBuilderImpl;
@@ -152,9 +152,9 @@
 		// now we modify the builder, get a new factory and valiator and try again
 		builder.constraintFactory(
 				new ConstraintFactory() {
-					public <T extends Constraint> T getInstance(Class<T> key) {
-						if ( key == NotNullConstraint.class ) {
-							return ( T ) new BadlyBehavedNotNullConstraint();
+					public <T extends ConstraintValidator> T getInstance(Class<T> key) {
+						if ( key == NotNullConstraintValidator.class ) {
+							return ( T ) new BadlyBehavedNotNullConstraintValidator();
 						}
 						return new ConstraintFactoryImpl().getInstance( key );
 					}
@@ -240,9 +240,9 @@
 		assertTrue( factory instanceof ValidatorFactoryImpl );
 	}
 
-	class BadlyBehavedNotNullConstraint extends NotNullConstraint {
+	class BadlyBehavedNotNullConstraintValidator extends NotNullConstraintValidator {
 		@Override
-		public boolean isValid(Object object, ConstraintContext constraintContext) {
+		public boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext) {
 			return true;
 		}
 	}

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthConstraintTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthConstraintTest.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthConstraintTest.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -18,7 +18,6 @@
 package org.hibernate.validation.constraints;
 
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -35,11 +34,11 @@
  */
 public class LengthConstraintTest {
 
-	LengthConstraint constraint;
+	LengthConstraintValidator constraint;
 
 	@Before
 	public void init() {
-		constraint = new LengthConstraint();
+		constraint = new LengthConstraintValidator();
 		constraint.initialize(
 				new Length() {
 

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyConstraintTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyConstraintTest.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyConstraintTest.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -17,8 +17,6 @@
 */
 package org.hibernate.validation.constraints;
 
-import java.lang.annotation.Annotation;
-
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -32,11 +30,11 @@
  */
 public class NotEmptyConstraintTest {
 
-	NotEmptyConstraint constraint;
+	NotEmptyConstraintValidator constraint;
 
 	@Before
 	public void init() {
-		constraint = new NotEmptyConstraint();
+		constraint = new NotEmptyConstraintValidator();
 	}
 
 	@Test

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotNullConstraintTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotNullConstraintTest.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotNullConstraintTest.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -28,7 +28,7 @@
 
 	@Test
 	public void testIsValid() {
-		NotNullConstraint constraint = new NotNullConstraint();
+		NotNullConstraintValidator constraint = new NotNullConstraintValidator();
 
 		assertFalse( constraint.isValid( null, null ) );
 		assertTrue( constraint.isValid( new Object(), null ) );

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternConstraintTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternConstraintTest.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternConstraintTest.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -32,11 +32,11 @@
  */
 public class PatternConstraintTest {
 
-	PatternConstraint constraint;
+	PatternConstraintValidator constraint;
 
 	@Before
 	public void init() {
-		constraint = new PatternConstraint();
+		constraint = new PatternConstraintValidator();
 		constraint.initialize(
 				new Pattern() {
 

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-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcode.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -24,7 +24,7 @@
 import java.lang.annotation.Retention;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import java.lang.annotation.Target;
-import javax.validation.ConstraintValidator;
+import javax.validation.Constraint;
 import javax.validation.OverridesParameter;
 import javax.validation.OverridesParameters;
 import javax.validation.constraints.NotNull;
@@ -40,7 +40,7 @@
 @Size
 // first pattern just duplicates the length of 5 characters, the second pattern is just to proof that parameters can be overridden.
 @Patterns({ @Pattern(regex = "....."), @Pattern(regex = "bar") })
- at ConstraintValidator(FrenchZipcodeConstraint.class)
+ at Constraint(validatedBy = FrenchZipcodeConstraintValidator.class)
 @Documented
 @Target({ METHOD, FIELD, TYPE })
 @Retention(RUNTIME)

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcodeConstraint.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcodeConstraint.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcodeConstraint.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -1,34 +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 org.hibernate.validation.constraints.composition;
-
-import javax.validation.Constraint;
-import javax.validation.ConstraintContext;
-
-/**
- * @author Hardy Ferentschik
- */
-public class FrenchZipcodeConstraint implements Constraint<FrenchZipcode> {
-
-	public void initialize(FrenchZipcode parameters) {
-	}
-
-	public boolean isValid(Object object, ConstraintContext constraintContext) {
-		return true;
-	}
-}

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcodeConstraintValidator.java (from rev 15815, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcodeConstraint.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcodeConstraintValidator.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcodeConstraintValidator.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -0,0 +1,34 @@
+// $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 org.hibernate.validation.constraints.composition;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class FrenchZipcodeConstraintValidator implements ConstraintValidator<FrenchZipcode> {
+
+	public void initialize(FrenchZipcode parameters) {
+	}
+
+	public boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext) {
+		return true;
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcodeConstraintValidator.java
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/GermanZipcode.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/GermanZipcode.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/GermanZipcode.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -24,7 +24,7 @@
 import java.lang.annotation.Retention;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import java.lang.annotation.Target;
-import javax.validation.ConstraintValidator;
+import javax.validation.Constraint;
 import javax.validation.ReportAsViolationFromCompositeConstraint;
 
 /**
@@ -33,7 +33,7 @@
  * @author Hardy Ferentschik
  */
 @FrenchZipcode
- at ConstraintValidator(GermanZipcodeConstraint.class)
+ at Constraint(validatedBy = GermanZipcodeConstraintValidator.class)
 @Documented
 @Target({ METHOD, FIELD, TYPE })
 @Retention(RUNTIME)

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/GermanZipcodeConstraint.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/GermanZipcodeConstraint.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/GermanZipcodeConstraint.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -1,34 +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 org.hibernate.validation.constraints.composition;
-
-import javax.validation.Constraint;
-import javax.validation.ConstraintContext;
-
-/**
- * @author Hardy Ferentschik
- */
-public class GermanZipcodeConstraint implements Constraint<GermanZipcode> {
-
-	public void initialize(GermanZipcode parameters) {
-	}
-
-	public boolean isValid(Object object, ConstraintContext constraintContext) {
-		return true;
-	}
-}
\ No newline at end of file

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/GermanZipcodeConstraintValidator.java (from rev 15815, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/GermanZipcodeConstraint.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/GermanZipcodeConstraintValidator.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/GermanZipcodeConstraintValidator.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -0,0 +1,34 @@
+// $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 org.hibernate.validation.constraints.composition;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class GermanZipcodeConstraintValidator implements ConstraintValidator<GermanZipcode> {
+
+	public void initialize(GermanZipcode parameters) {
+	}
+
+	public boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext) {
+		return true;
+	}
+}
\ No newline at end of file


Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/GermanZipcodeConstraintValidator.java
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/UKZipcode.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/UKZipcode.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/UKZipcode.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -24,7 +24,7 @@
 import java.lang.annotation.Retention;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import java.lang.annotation.Target;
-import javax.validation.ConstraintValidator;
+import javax.validation.Constraint;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
 
@@ -33,7 +33,7 @@
  */
 @NotNull
 @Size(min = 5, max = 5)
- at ConstraintValidator(UKZipcodeConstraint.class)
+ at Constraint(validatedBy = UKZipcodeConstraintValidator.class)
 @Documented
 @Target({ METHOD, FIELD, TYPE })
 @Retention(RUNTIME)

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/UKZipcodeConstraint.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/UKZipcodeConstraint.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/UKZipcodeConstraint.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -1,34 +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 org.hibernate.validation.constraints.composition;
-
-import javax.validation.Constraint;
-import javax.validation.ConstraintContext;
-
-/**
- * @author Hardy Ferentschik
- */
-public class UKZipcodeConstraint implements Constraint<UKZipcode> {
-
-	public void initialize(UKZipcode parameters) {
-	}
-
-	public boolean isValid(Object object, ConstraintContext constraintContext) {
-		return false;
-	}
-}
\ No newline at end of file

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/UKZipcodeConstraintValidator.java (from rev 15815, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/UKZipcodeConstraint.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/UKZipcodeConstraintValidator.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/UKZipcodeConstraintValidator.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -0,0 +1,34 @@
+// $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 org.hibernate.validation.constraints.composition;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class UKZipcodeConstraintValidator implements ConstraintValidator<UKZipcode> {
+
+	public void initialize(UKZipcode parameters) {
+	}
+
+	public boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext) {
+		return false;
+	}
+}
\ No newline at end of file


Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/UKZipcodeConstraintValidator.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:mergeinfo
   + 

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoGroups.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoGroups.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoGroups.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -23,15 +23,15 @@
 import java.lang.annotation.Retention;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import java.lang.annotation.Target;
-import javax.validation.ConstraintValidator;
+import javax.validation.Constraint;
 
-import org.hibernate.validation.constraints.incomplete.NoGroupsConstraint;
+import org.hibernate.validation.constraints.incomplete.NoGroupsConstraintValidator;
 
 /**
  * @author Hardy Ferentschik
  */
 @Documented
- at ConstraintValidator(NoGroupsConstraint.class)
+ at Constraint(validatedBy = NoGroupsConstraintValidator.class)
 @Target({ METHOD, FIELD })
 @Retention(RUNTIME)
 public @interface NoGroups {

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoGroupsConstraint.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoGroupsConstraint.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoGroupsConstraint.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -1,36 +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 org.hibernate.validation.constraints.incomplete;
-
-import javax.validation.Constraint;
-import javax.validation.ConstraintContext;
-
-import org.hibernate.validation.constraints.incomplete.NoGroups;
-
-/**
- * @author Hardy Ferentschik
- */
-public class NoGroupsConstraint implements Constraint<NoGroups> {
-
-	public void initialize(NoGroups parameters) {
-	}
-
-	public boolean isValid(Object object, ConstraintContext constraintContext) {
-		return false;
-	}
-}
\ No newline at end of file

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoGroupsConstraintValidator.java (from rev 15815, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoGroupsConstraint.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoGroupsConstraintValidator.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoGroupsConstraintValidator.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -0,0 +1,36 @@
+// $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 org.hibernate.validation.constraints.incomplete;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+import org.hibernate.validation.constraints.incomplete.NoGroups;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class NoGroupsConstraintValidator implements ConstraintValidator<NoGroups> {
+
+	public void initialize(NoGroups parameters) {
+	}
+
+	public boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext) {
+		return false;
+	}
+}
\ No newline at end of file


Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoGroupsConstraintValidator.java
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoMessage.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoMessage.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoMessage.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -23,13 +23,13 @@
 import java.lang.annotation.Retention;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import java.lang.annotation.Target;
-import javax.validation.ConstraintValidator;
+import javax.validation.Constraint;
 
 /**
  * @author Hardy Ferentschik
  */
 @Documented
- at ConstraintValidator(NoMessageConstraint.class)
+ at Constraint(validatedBy = NoMessageConstraintValidator.class)
 @Target({ METHOD, FIELD })
 @Retention(RUNTIME)
 public @interface NoMessage {

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoMessageConstraint.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoMessageConstraint.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoMessageConstraint.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -1,34 +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 org.hibernate.validation.constraints.incomplete;
-
-import javax.validation.Constraint;
-import javax.validation.ConstraintContext;
-
-/**
- * @author Hardy Ferentschik
- */
-public class NoMessageConstraint implements Constraint<NoMessage> {
-
-	public void initialize(NoMessage parameters) {
-	}
-
-	public boolean isValid(Object object, ConstraintContext constraintContext) {
-		return false;
-	}
-}
\ No newline at end of file

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoMessageConstraintValidator.java (from rev 15815, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoMessageConstraint.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoMessageConstraintValidator.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoMessageConstraintValidator.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -0,0 +1,34 @@
+// $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 org.hibernate.validation.constraints.incomplete;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class NoMessageConstraintValidator implements ConstraintValidator<NoMessage> {
+
+	public void initialize(NoMessage parameters) {
+	}
+
+	public boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext) {
+		return false;
+	}
+}
\ No newline at end of file


Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/NoMessageConstraintValidator.java
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/ValidProperty.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/ValidProperty.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/incomplete/ValidProperty.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -23,13 +23,13 @@
 import java.lang.annotation.Retention;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import java.lang.annotation.Target;
-import javax.validation.ConstraintValidator;
+import javax.validation.Constraint;
 
 /**
  * @author Hardy Ferentschik
  */
 @Documented
- at ConstraintValidator(NoGroupsConstraint.class)
+ at Constraint(validatedBy = NoGroupsConstraintValidator.class)
 @Target({ METHOD, FIELD })
 @Retention(RUNTIME)
 public @interface ValidProperty {

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ConstraintCompositionTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ConstraintCompositionTest.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ConstraintCompositionTest.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -24,10 +24,10 @@
 import static org.junit.Assert.fail;
 import org.junit.Test;
 
-import org.hibernate.validation.constraints.NotNullConstraint;
-import org.hibernate.validation.constraints.PatternConstraint;
-import org.hibernate.validation.constraints.SizeConstraint;
-import org.hibernate.validation.constraints.composition.GermanZipcodeConstraint;
+import org.hibernate.validation.constraints.NotNullConstraintValidator;
+import org.hibernate.validation.constraints.PatternConstraintValidator;
+import org.hibernate.validation.constraints.SizeConstraintValidator;
+import org.hibernate.validation.constraints.composition.GermanZipcodeConstraintValidator;
 import org.hibernate.validation.eg.FrenchAddress;
 import org.hibernate.validation.eg.GermanAddress;
 import static org.hibernate.validation.util.TestUtil.assertConstraintViolation;
@@ -54,7 +54,7 @@
 		assertConstraintViolation(
 				constraintViolations.iterator().next(),
 				"may not be null",
-				NotNullConstraint.class,
+				NotNullConstraintValidator.class,
 				FrenchAddress.class,
 				null,
 				"zipCode"
@@ -69,7 +69,7 @@
 				assertConstraintViolation(
 						violation,
 						"A french zip code has a length of 5",
-						SizeConstraint.class,
+						SizeConstraintValidator.class,
 						FrenchAddress.class,
 						"abc",
 						"zipCode"
@@ -79,7 +79,7 @@
 				assertConstraintViolation(
 						violation,
 						"must match \"d*\"",
-						PatternConstraint.class,
+						PatternConstraintValidator.class,
 						FrenchAddress.class,
 						"abc",
 						"zipCode"
@@ -89,7 +89,7 @@
 				assertConstraintViolation(
 						violation,
 						"must match \".....\"",
-						PatternConstraint.class,
+						PatternConstraintValidator.class,
 						FrenchAddress.class,
 						"abc",
 						"zipCode"
@@ -109,7 +109,7 @@
 				assertConstraintViolation(
 						violation,
 						"A french zip code has a length of 5",
-						SizeConstraint.class,
+						SizeConstraintValidator.class,
 						FrenchAddress.class,
 						"123",
 						"zipCode"
@@ -119,7 +119,7 @@
 				assertConstraintViolation(
 						violation,
 						"must match \".....\"",
-						PatternConstraint.class,
+						PatternConstraintValidator.class,
 						FrenchAddress.class,
 						"123",
 						"zipCode"
@@ -148,7 +148,7 @@
 		assertConstraintViolation(
 				constraintViolations.iterator().next(),
 				"Falsche Postnummer.",
-				GermanZipcodeConstraint.class,
+				GermanZipcodeConstraintValidator.class,
 				GermanAddress.class,
 				null,
 				"zipCode"
@@ -170,7 +170,7 @@
 		assertConstraintViolation(
 				constraintViolations.iterator().next(),
 				"Falsche Postnummer.",
-				GermanZipcodeConstraint.class,
+				GermanZipcodeConstraintValidator.class,
 				GermanAddress.class,
 				"abc",
 				"zipCode"

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -88,7 +88,7 @@
 		assertEquals(
 				"Wrong constraint error Type",
 				constraintType,
-				violation.getConstraintDescriptor().getConstraintClass()
+				violation.getConstraintDescriptor().getConstraintValidatorClass()
 		);
 		assertConstraintViolation( violation, errorMessage );
 	}

Deleted: validator/trunk/validation-api/src/main/java/javax/validation/Constraint.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/Constraint.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/validation-api/src/main/java/javax/validation/Constraint.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -1,51 +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.lang.annotation.Annotation;
-
-/**
- * Define the logic to validate a given constraint.
- *
- * @author Emmanuel Bernard
- * @author Hardy Ferentschik
- */
-public interface Constraint<A extends Annotation> {
-	/**
-	 * Validator parameters for a given constraint definition
-	 * Annotations parameters are passed as key/value into parameters
-	 * <p/>
-	 * This method is guaranteed to be called before any of the other Constraint
-	 * implementation methods
-	 *
-	 * @param constraintAnnotation parameters for a given constraint definition
-	 */
-	void initialize(A constraintAnnotation);
-
-	/**
-	 * Implement the validation constraint.
-	 * <code>object</code> state must not be changed by a Constraint implementation
-	 *
-	 * @param object object to validate
-	 * @param constraintContext context in which the constraint implementation is evaluated
-	 *
-	 * @return false if <code>object</code> does not pass the constraint
-	 */
-	boolean isValid(Object object, ConstraintContext constraintContext);
-}
- 
\ No newline at end of file

Added: validator/trunk/validation-api/src/main/java/javax/validation/Constraint.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/Constraint.java	                        (rev 0)
+++ validator/trunk/validation-api/src/main/java/javax/validation/Constraint.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -0,0 +1,45 @@
+// $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.Documented;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+
+/**
+ * Link between a constraint annotation and it's constraint validation implementation.
+ * <p/>
+ * An given constraint annotation should be annotated by a @ConstraintValidator
+ * annotation which refers to its constraint validation implementation.
+ *
+ * @author Emmanuel Bernard (emmanuel at hibernate.org)
+ * @author Gavin King
+ * @author Hardy Ferentschik
+ */
+ at Documented
+ at Target({ ANNOTATION_TYPE })
+ at Retention(RUNTIME)
+public @interface Constraint {
+	/**
+	 * @return The class implementing the constraint validation logic
+	 */
+	public abstract Class<? extends ConstraintValidator> validatedBy();
+}
\ No newline at end of file

Deleted: validator/trunk/validation-api/src/main/java/javax/validation/ConstraintContext.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/ConstraintContext.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/validation-api/src/main/java/javax/validation/ConstraintContext.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -1,60 +0,0 @@
-package javax.validation;
-
-/**
- * Provide contextual data and operation when applying a given constraint implementation
- *
- * @author Emmanuel Bernard
- */
-public interface ConstraintContext {
-	/**
-	 * 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)
-	 * @see #addError(String, String)
-	 */
-	void disableDefaultError();
-
-	/**
-	 * @return the current unexpanded default message
-	 * TODO: is it needed
-	 */
-	String getDefaultErrorMessage();
-
-	/**
-	 * Add a new error message. This error message will be interpolated.
-	 * <p/>
-	 * 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, 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 ConstraintViolation instance per
-	 * call is created.
-	 *
-	 * @param message new unexpanded error message
-	 */
-	void addError(String message);
-
-	/**
-	 * Add a new error message to a given sub property <code>property</code>.
-	 * This error message will be interpolated.
-	 * <p/>
-	 * If isValid returns false, a ConstraintViolation object will be built
-	 * per error message including the default one unless #disableDefaultErrorMEssage()
-	 * has been called.
-	 * If the constraint being validated is not a class-level constraint,
-	 * a ValidationException is raised.
-	 *
-	 * <p/>
-	 *
-	 * @param message new unexpanded error message
-	 * @param property property name the ConstraintViolation is targeting
-	 *
-	 * @throws ValidationException if the constraint is not set on a class-level
-	 */
-	void addError(String message, String property);
-
-}

Modified: validator/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -43,9 +43,9 @@
 	Set<Class<?>> getGroups();
 
 	/**
-	 * @return the constraint implementation class
+	 * @return the constraint validation implementation class
 	 */
-	Class<? extends Constraint> getConstraintClass();
+	Class<? extends ConstraintValidator> getConstraintValidatorClass();
 
 	/**
 	 * Returns a map containing the annotation parameter names as keys and the

Modified: validator/trunk/validation-api/src/main/java/javax/validation/ConstraintFactory.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/ConstraintFactory.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/validation-api/src/main/java/javax/validation/ConstraintFactory.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -18,8 +18,8 @@
 package javax.validation;
 
 /**
- * Instantiate a <code>Constraint</code> instance from its class.
- * The <code>ConstraintFactory</code> is <b>not</b> responsible for calling {@link Constraint#initialize(java.lang.annotation.Annotation)}.
+ * Instantiate a <code>ConstraintValidator</code> instance from its class.
+ * The <code>ConstraintFactory</code> is <b>not</b> responsible for calling {@link ConstraintValidator#initialize(java.lang.annotation.Annotation)}.
  *
  * @author Dhanji R. Prasanna
  * @author Emmanuel Bernard
@@ -28,9 +28,9 @@
 public interface ConstraintFactory {
 
 	/**
-	 * @param key The class of the constraint to instantiate.
+	 * @param key The class of the constraint validator to instantiate.
 	 *
-	 * @return An constraint instance of the specified class.
+	 * @return An constraint validator instance of the specified class.
 	 */
-	<T extends Constraint> T getInstance(Class<T> key);
+	<T extends ConstraintValidator> T getInstance(Class<T> key);
 }

Deleted: validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -1,46 +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.lang.annotation.Documented;
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
-import java.lang.annotation.Retention;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import java.lang.annotation.Target;
-
-
-/**
- * Link between a constraint annotation and it's constraint validation implementation.
- * <p/>
- * An given constraint annotation should be annotated by a @ConstraintValidator
- * annotation which refers to its constraint validation implementation.
- *
- * @author Emmanuel Bernard (emmanuel at hibernate.org)
- * @author Gavin King
- * @author Hardy Ferentschik
- */
- at Documented
- at Target({ ANNOTATION_TYPE })
- at Retention(RUNTIME)
-public @interface ConstraintValidator {
-	/**
-	 * @return The class implementing the constraint validation logic for the constraint annotation this annotation
-	 * is used on.
-	 */
-	public abstract Class<? extends Constraint> value();
-}
\ No newline at end of file

Copied: validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java (from rev 15815, validator/trunk/validation-api/src/main/java/javax/validation/Constraint.java)
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java	                        (rev 0)
+++ validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -0,0 +1,51 @@
+// $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.Annotation;
+
+/**
+ * Define the logic to validate a given constraint.
+ *
+ * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
+ */
+public interface ConstraintValidator<A extends Annotation> {
+	/**
+	 * Validator parameters for a given constraint definition
+	 * Annotations parameters are passed as key/value into parameters
+	 * <p/>
+	 * This method is guaranteed to be called before any of the other Constraint
+	 * implementation methods
+	 *
+	 * @param constraintAnnotation parameters for a given constraint definition
+	 */
+	void initialize(A constraintAnnotation);
+
+	/**
+	 * Implement the validation constraint.
+	 * <code>object</code> state must not be changed by a Constraint implementation
+	 *
+	 * @param object object to validate
+	 * @param constraintValidatorContext context in which the constraint is evaluated
+	 *
+	 * @return false if <code>object</code> does not pass the constraint
+	 */
+	boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext);
+}
+ 
\ No newline at end of file


Property changes on: validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:mergeinfo
   + 

Copied: validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java (from rev 15815, validator/trunk/validation-api/src/main/java/javax/validation/ConstraintContext.java)
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java	                        (rev 0)
+++ validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -0,0 +1,60 @@
+package javax.validation;
+
+/**
+ * Provide contextual data and operation when applying a given constraint validator implementation
+ *
+ * @author Emmanuel Bernard
+ */
+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
+	 * a different property
+	 *
+	 * @see #addError(String)
+	 * @see #addError(String, String)
+	 */
+	void disableDefaultError();
+
+	/**
+	 * @return the current unexpanded default message
+	 * TODO: is it needed
+	 */
+	String getDefaultErrorMessage();
+
+	/**
+	 * Add a new error message. This error message will be interpolated.
+	 * <p/>
+	 * 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, 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 ConstraintViolation instance per
+	 * call is created.
+	 *
+	 * @param message new unexpanded error message
+	 */
+	void addError(String message);
+
+	/**
+	 * Add a new error message to a given sub property <code>property</code>.
+	 * This error message will be interpolated.
+	 * <p/>
+	 * If isValid returns false, a ConstraintViolation object will be built
+	 * per error message including the default one unless #disableDefaultErrorMEssage()
+	 * has been called.
+	 * If the constraint being validated is not a class-level constraint,
+	 * a ValidationException is raised.
+	 *
+	 * <p/>
+	 *
+	 * @param message new unexpanded error message
+	 * @param property property name the ConstraintViolation is targeting
+	 *
+	 * @throws ValidationException if the constraint is not set on a class-level
+	 */
+	void addError(String message, String property);
+
+}


Property changes on: validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java
___________________________________________________________________
Name: svn:keywords
   + Id

Deleted: validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/FineGrainedLengthConstraint.java
===================================================================
--- validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/FineGrainedLengthConstraint.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/FineGrainedLengthConstraint.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -1,54 +0,0 @@
-package org.hibernate.validator.spec.s2.s4;
-
-import javax.validation.ConstraintContext;
-import javax.validation.Constraint;
-
-/**
- * Check that a string length is between min and max
- * Error messages are using either key:
- *  - constraint.length.min if the min limit is reached
- *  - constraint.length.max if the max limit is reached
- */
-public class FineGrainedLengthConstraint implements Constraint<Length> {
-    private int min;
-    private int max;
-
-    /**
-     * Configure the constraint validator based on the elements
-     * specified at the time it was defined.
-     * @param constraint the constraint definition
-     */
-    public void initialize(Length constraint) {
-        min = constraint.min();
-        max = constraint.max();
-    }
-
-    /**
-     * Validate a specified value.
-     * returns false if the specified value does not conform to the definition
-     * @exception IllegalArgumentException if the object is not of type String
-     */
-    public boolean isValid(Object value, ConstraintContext constraintContext) {
-        if ( value == null ) return true;
-        if ( !( value instanceof String ) ) {
-            throw new IllegalArgumentException("Expected String type");
-        }
-        String string = (String) value;
-        int length = string.length();
-
-		//remove default error
-		constraintContext.disableDefaultError();
-
-		if (length < min) {
-			//add min specific error
-			constraintContext.addError( "{constraint.length.min}" );
-			return false;
-		}
-		if (length > max) {
-			//add max specific error
-			constraintContext.addError( "{constraint.length.max}" );
-			return false;
-		}
-		return true;
-    }
-}
\ No newline at end of file

Copied: validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/FineGrainedLengthConstraintValidator.java (from rev 15815, validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/FineGrainedLengthConstraint.java)
===================================================================
--- validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/FineGrainedLengthConstraintValidator.java	                        (rev 0)
+++ validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/FineGrainedLengthConstraintValidator.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -0,0 +1,54 @@
+package org.hibernate.validator.spec.s2.s4;
+
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.ConstraintValidator;
+
+/**
+ * Check that a string length is between min and max
+ * Error messages are using either key:
+ *  - constraint.length.min if the min limit is reached
+ *  - constraint.length.max if the max limit is reached
+ */
+public class FineGrainedLengthConstraintValidator implements ConstraintValidator<Length> {
+    private int min;
+    private int max;
+
+    /**
+     * Configure the constraint validator based on the elements
+     * specified at the time it was defined.
+     * @param constraint the constraint definition
+     */
+    public void initialize(Length constraint) {
+        min = constraint.min();
+        max = constraint.max();
+    }
+
+    /**
+     * Validate a specified value.
+     * returns false if the specified value does not conform to the definition
+     * @exception IllegalArgumentException if the object is not of type String
+     */
+    public boolean isValid(Object value, ConstraintValidatorContext constraintValidatorContext) {
+        if ( value == null ) return true;
+        if ( !( value instanceof String ) ) {
+            throw new IllegalArgumentException("Expected String type");
+        }
+        String string = (String) value;
+        int length = string.length();
+
+		//remove default error
+		constraintValidatorContext.disableDefaultError();
+
+		if (length < min) {
+			//add min specific error
+			constraintValidatorContext.addError( "{constraint.length.min}" );
+			return false;
+		}
+		if (length > max) {
+			//add max specific error
+			constraintValidatorContext.addError( "{constraint.length.max}" );
+			return false;
+		}
+		return true;
+    }
+}
\ No newline at end of file


Property changes on: validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/FineGrainedLengthConstraintValidator.java
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/Length.java
===================================================================
--- validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/Length.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/Length.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -7,7 +7,7 @@
 import static java.lang.annotation.ElementType.METHOD;
 import static java.lang.annotation.ElementType.FIELD;
 import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
-import javax.validation.ConstraintValidator;
+import javax.validation.Constraint;
 
 /**
  * @author Emmanuel Bernard
@@ -15,7 +15,7 @@
 @Target({ METHOD, FIELD, ANNOTATION_TYPE })
 @Retention(RUNTIME)
 @Documented
- at ConstraintValidator(LengthConstraint.class)
+ at Constraint(validatedBy = LengthConstraintValidator.class)
 public @interface Length {
 	int min() default Integer.MIN_VALUE;
 	int max() default Integer.MAX_VALUE;

Deleted: validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/LengthConstraint.java
===================================================================
--- validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/LengthConstraint.java	2009-01-25 20:44:59 UTC (rev 15816)
+++ validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/LengthConstraint.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -1,38 +0,0 @@
-package org.hibernate.validator.spec.s2.s4;
-
-import javax.validation.ConstraintContext;
-import javax.validation.Constraint;
-
-/**
- * Check that a string length is between min and max
- *
- */
-public class LengthConstraint implements Constraint<Length> {
-    private int min;
-    private int max;
-
-    /**
-     * Configure the constraint validator based on the elements
-     * specified at the time it was defined.
-     * @param constraint the constraint definition
-     */
-    public void initialize(Length constraint) {
-        min = constraint.min();
-        max = constraint.max();
-    }
-
-    /**
-     * Validate a specified value.
-     * returns false if the specified value does not conform to the definition
-     * @exception IllegalArgumentException if the object is not of type String
-     */
-    public boolean isValid(Object value, ConstraintContext constraintContext) {
-        if ( value == null ) return true;
-        if ( !( value instanceof String ) ) {
-            throw new IllegalArgumentException("Expected String type");
-        }
-        String string = (String) value;
-        int length = string.length();
-        return length >= min && length <= max;
-    }
-}

Copied: validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/LengthConstraintValidator.java (from rev 15815, validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/LengthConstraint.java)
===================================================================
--- validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/LengthConstraintValidator.java	                        (rev 0)
+++ validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/LengthConstraintValidator.java	2009-01-25 22:35:36 UTC (rev 15817)
@@ -0,0 +1,38 @@
+package org.hibernate.validator.spec.s2.s4;
+
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.ConstraintValidator;
+
+/**
+ * Check that a string length is between min and max
+ *
+ */
+public class LengthConstraintValidator implements ConstraintValidator<Length> {
+    private int min;
+    private int max;
+
+    /**
+     * Configure the constraint validator based on the elements
+     * specified at the time it was defined.
+     * @param constraint the constraint definition
+     */
+    public void initialize(Length constraint) {
+        min = constraint.min();
+        max = constraint.max();
+    }
+
+    /**
+     * Validate a specified value.
+     * returns false if the specified value does not conform to the definition
+     * @exception IllegalArgumentException if the object is not of type String
+     */
+    public boolean isValid(Object value, ConstraintValidatorContext constraintValidatorContext) {
+        if ( value == null ) return true;
+        if ( !( value instanceof String ) ) {
+            throw new IllegalArgumentException("Expected String type");
+        }
+        String string = (String) value;
+        int length = string.length();
+        return length >= min && length <= max;
+    }
+}


Property changes on: validator/trunk/validation-api/src/test/java/org/hibernate/validator/spec/s2/s4/LengthConstraintValidator.java
___________________________________________________________________
Name: svn:keywords
   + Id




More information about the hibernate-commits mailing list