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

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Thu Oct 23 11:48:19 EDT 2008


Author: hardy.ferentschik
Date: 2008-10-23 11:48:18 -0400 (Thu, 23 Oct 2008)
New Revision: 15383

Removed:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNull.java
Modified:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullConstraint.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaDataProviderImpl.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/test/java/org/hibernate/validation/eg/Address.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Animal.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Author.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Book.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Boy.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Dictonary.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Order.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Person.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/impl/ResourceBundleMessageResolverTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ReflectionHelperTest.java
   validator/trunk/validation-api/src/main/java/javax/validation/ConstraintFactory.java
   validator/trunk/validation-api/src/main/java/javax/validation/constraints/AssertFalse.java
   validator/trunk/validation-api/src/main/java/javax/validation/constraints/AssertTrue.java
   validator/trunk/validation-api/src/main/java/javax/validation/constraints/Digits.java
   validator/trunk/validation-api/src/main/java/javax/validation/constraints/Future.java
   validator/trunk/validation-api/src/main/java/javax/validation/constraints/Max.java
   validator/trunk/validation-api/src/main/java/javax/validation/constraints/Min.java
   validator/trunk/validation-api/src/main/java/javax/validation/constraints/NotNull.java
   validator/trunk/validation-api/src/main/java/javax/validation/constraints/Null.java
   validator/trunk/validation-api/src/main/java/javax/validation/constraints/Past.java
   validator/trunk/validation-api/src/main/java/javax/validation/constraints/Size.java
Log:
* Started to implement BVAL-31
* Removed org.hibernate.validator.constraint.NotNull
* Javadoc changes

Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNull.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNull.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNull.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -1,39 +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.lang.annotation.Documented;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import java.lang.annotation.Retention;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import java.lang.annotation.Target;
-import javax.validation.ConstraintValidator;
-
-/**
- * @author Emmanuel Bernard
- */
- at Documented
- at ConstraintValidator(NotNullConstraint.class)
- at Target({ METHOD, FIELD })
- at Retention(RUNTIME)
-public @interface NotNull {
-	public abstract String message() default "{validator.notNull}";
-
-	public abstract String[] groups() default { };
-}

Modified: 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	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullConstraint.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -19,6 +19,7 @@
 
 import javax.validation.Constraint;
 import javax.validation.Context;
+import javax.validation.constraints.NotNull;
 
 /**
  * Validate that the object is not <code>null</code>.

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaDataProviderImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaDataProviderImpl.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaDataProviderImpl.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -247,20 +247,31 @@
 		constraintCandidates.addAll( Arrays.asList( annotations ) );
 
 		for ( Annotation constraintCandiate : constraintCandidates ) {
-			ConstraintValidator constraintValidator = constraintCandiate.annotationType()
-					.getAnnotation( ConstraintValidator.class );
-			if ( constraintValidator != null ) {
-				final ConstraintDescriptorImpl constraintDescriptor = buildConstraintDescriptor( constraintCandiate );
+
+			if ( ReflectionHelper.isBuiltInConstraintAnnotation( constraintCandiate ) ) {
+				Class constraintClass = ReflectionHelper.getBuiltInConstraint( constraintCandiate );
+				final ConstraintDescriptorImpl constraintDescriptor = buildConstraintDescriptor(
+						constraintCandiate, constraintClass
+				);
 				constraintDescriptors.add( constraintDescriptor );
+				continue;
 			}
+
+			if ( ReflectionHelper.isConstraintAnnotation( constraintCandiate ) ) {
+				ConstraintValidator constraintValidator = constraintCandiate.annotationType()
+						.getAnnotation( ConstraintValidator.class );
+				final ConstraintDescriptorImpl constraintDescriptor = buildConstraintDescriptor(
+						constraintCandiate, constraintValidator.value()
+				);
+				constraintDescriptors.add( constraintDescriptor );
+			}
 		}
 		return constraintDescriptors;
 	}
 
 	@SuppressWarnings("unchecked")
-	private <A extends Annotation> ConstraintDescriptorImpl buildConstraintDescriptor(A annotation) {
-		getMessage( annotation ); // called to make sure there is a message
-		String[] groups = getGroups( annotation );
+	private <A extends Annotation> ConstraintDescriptorImpl buildConstraintDescriptor(A annotation, Class constraintClass) {
+		String[] groups = ReflectionHelper.getAnnotationParameter( annotation, "groups", String[].class );
 		for ( String groupName : groups ) {
 			if ( groupSequences.containsKey( groupName ) ) {
 				throw new ValidationException( groupName + " is illegally used as group and sequence name." );
@@ -268,52 +279,24 @@
 		}
 
 		Constraint<A> constraint;
-		ConstraintValidator constraintValidator = annotation.annotationType()
-				.getAnnotation( ConstraintValidator.class );
 		try {
 			//unchecked
-			constraint = constraintFactory.getInstance( constraintValidator.value() );
+			constraint = constraintFactory.getInstance( constraintClass );
 		}
 		catch ( RuntimeException e ) {
-			throw new ValidationException( "Unable to instantiate " + constraintValidator.value(), e );
+			throw new ValidationException( "Unable to instantiate " + constraintClass, e );
 		}
 
 		try {
 			constraint.initialize( annotation );
 		}
 		catch ( RuntimeException e ) {
-			throw new ValidationException( "Unable to intialize " + constraintValidator.value(), e );
+			throw new ValidationException( "Unable to intialize " + constraint.getClass().getName(), e );
 		}
 
-		return new ConstraintDescriptorImpl( annotation, groups, constraint, constraintValidator.value() );
+		return new ConstraintDescriptorImpl( annotation, groups, constraint, constraintClass );
 	}
 
-	private <A extends Annotation> String getMessage(A annotation) {
-		try {
-			Method m = annotation.getClass().getMethod( "message" );
-			return ( String ) m.invoke( annotation );
-		}
-		catch ( NoSuchMethodException e ) {
-			throw new ValidationException( "Constraint annotation has to define message element." );
-		}
-		catch ( Exception e ) {
-			throw new ValidationException( "Unable to get message from " + annotation.getClass().getName() );
-		}
-	}
-
-	private <A extends Annotation> String[] getGroups(A annotation) {
-		try {
-			Method m = annotation.getClass().getMethod( "groups" );
-			return ( String[] ) m.invoke( annotation );
-		}
-		catch ( NoSuchMethodException e ) {
-			throw new ValidationException( "Constraint annotation has to define groups element." );
-		}
-		catch ( Exception e ) {
-			throw new ValidationException( "Unable to get groups from " + annotation.getClass().getName() );
-		}
-	}
-
 	/**
 	 * Checks whether the given annotation has a value parameter which returns an array of annotations.
 	 *

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	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/impl/ConstraintFactoryImpl.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -27,6 +27,10 @@
  * @author Emmanuel Bernard
  */
 public class ConstraintFactoryImpl implements ConstraintFactory {
+	
+	/**
+	 * {@inheritDoc}
+	 */
 	public <T extends Constraint> 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	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -18,6 +18,7 @@
 package org.hibernate.validation.util;
 
 import java.beans.Introspector;
+import java.lang.annotation.Annotation;
 import java.lang.reflect.AccessibleObject;
 import java.lang.reflect.Field;
 import java.lang.reflect.GenericArrayType;
@@ -28,13 +29,17 @@
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.lang.reflect.WildcardType;
+import java.util.Arrays;
 import java.util.Collection;
-import java.util.Map;
 import java.util.Iterator;
-import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
+import javax.validation.ConstraintValidator;
 import javax.validation.ValidationException;
+import javax.validation.constraints.NotNull;
 
+import org.hibernate.validation.constraints.NotNullConstraint;
+
 /**
  * Some reflection utility methods.
  *
@@ -42,10 +47,91 @@
  */
 public class ReflectionHelper {
 
+	/**
+	 * Private constructor in order to avoid instantiation.
+	 */
 	private ReflectionHelper() {
 	}
 
+
 	/**
+	 * @todo Maybe move into another class
+	 * @todo Read mappings for example from a resource file
+	 */
+	public static Class getBuiltInConstraint(Annotation annotation) {
+		if ( annotation instanceof NotNull ) {
+			return NotNullConstraint.class;
+		}
+		else {
+			return null;
+		}
+	}
+
+	public static boolean isBuiltInConstraintAnnotation(Annotation annotation) {
+		boolean isBuiltInConstraintAnnotation = false;
+
+		String packageName = annotation.annotationType().getPackage().getName();
+		if ( "javax.validation.constraints".equals( packageName ) ) {
+			isBuiltInConstraintAnnotation = true;
+		}
+		return isBuiltInConstraintAnnotation;
+	}
+
+	public static boolean isConstraintAnnotation(Annotation annotation) {
+		boolean isConstraintAnnotation = true;
+
+		ConstraintValidator constraintValidator = annotation.annotationType()
+				.getAnnotation( ConstraintValidator.class );
+		if ( constraintValidator == null ) {
+			isConstraintAnnotation = false;
+			return isConstraintAnnotation;
+		}
+
+		try {
+			getAnnotationParameter( annotation, "message", String.class );
+		} 	catch ( Exception e ) {
+			throw new ValidationException( "Constraint annotation has to define message element." );
+		}
+
+		try {
+			getAnnotationParameter( annotation, "groups", String[].class );
+		}
+		catch ( Exception e ) {
+			throw new ValidationException( "Constraint annotation has to define groups element." );
+		}
+
+		return isConstraintAnnotation;
+	}
+
+
+	@SuppressWarnings("unchecked")
+	public static <T> T getAnnotationParameter(Annotation annotation, String parameterName, Class<T> type) {
+		try {
+			Method m = annotation.getClass().getMethod( parameterName );
+			Object o = m.invoke( annotation );
+			if ( o.getClass().getName().equals( type.getName() ) ) {
+				return ( T ) o;
+			}
+			else {
+				String msg = "Wrong parameter type. Expected: " + type.getName() + " Actual: " + o.getClass().getName();
+				throw new ValidationException( msg );
+			}
+		}
+		catch ( NoSuchMethodException e ) {
+			String msg = "The specified annotation defines no parameter '" + parameterName + "'.";
+			throw new ValidationException( msg, e );
+		}
+		catch ( IllegalAccessException e ) {
+			String msg = "Unable to get '" + parameterName + "' from " + annotation.getClass().getName();
+			throw new ValidationException( msg, e );
+		}
+		catch ( InvocationTargetException e ) {
+			String msg = "Unable to get '" + parameterName + "' from " + annotation.getClass().getName();
+			throw new ValidationException( msg, e );
+		}
+	}
+
+	/**
 	 * Process bean properties getter by applying the JavaBean naming conventions.
 	 *
 	 * @param member the member for which to get the property name.
@@ -233,20 +319,20 @@
 	 * @return <code>true</code> is <code>clazz</code> is instance of a collection class, <code>false</code> otherwise.
 	 */
 	private static boolean isCollectionClass(Class<?> clazz) {
-        Class[] interfaces = clazz.getInterfaces();
+		Class[] interfaces = clazz.getInterfaces();
 
-        for ( Class interfaceClass : interfaces) {
-            if (interfaceClass == Collection.class
-				|| interfaceClass == java.util.List.class
-				|| interfaceClass == java.util.Set.class
-				|| interfaceClass == java.util.Map.class
-				|| interfaceClass == java.util.SortedSet.class // extension to the specs
-				|| interfaceClass == java.util.SortedMap.class) { // extension to the specs)
-                return true;
-            }
-        }
+		for ( Class interfaceClass : interfaces ) {
+			if ( interfaceClass == Collection.class
+					|| interfaceClass == java.util.List.class
+					|| interfaceClass == java.util.Set.class
+					|| interfaceClass == java.util.Map.class
+					|| interfaceClass == java.util.SortedSet.class // extension to the specs
+					|| interfaceClass == java.util.SortedMap.class ) { // extension to the specs)
+				return true;
+			}
+		}
 
-        return false;
+		return false;
 	}
 
 	/**
@@ -256,8 +342,9 @@
 	 * either a collection or array.
 	 * @param index The index. The index does not have to be numerical. <code>value</code> could also be a map in which
 	 * case the index could also be a string key.
+	 *
 	 * @return The indexed value or <code>null</code> if <code>value</code> is <code>null</code> or not a collection or array.
-	 * <code>null</code> is also returned in case the index does not exist.
+	 *         <code>null</code> is also returned in case the index does not exist.
 	 */
 	public static Object getIndexedValue(Object value, String index) {
 		if ( value == null ) {

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Address.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Address.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Address.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -17,8 +17,9 @@
 */
 package org.hibernate.validation.eg;
 
+import javax.validation.constraints.NotNull;
+
 import org.hibernate.validation.constraints.Length;
-import org.hibernate.validation.constraints.NotNull;
 
 /**
  * @author Hardy Ferentschik

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Animal.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Animal.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Animal.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -17,8 +17,9 @@
 */
 package org.hibernate.validation.eg;
 
+import javax.validation.constraints.NotNull;
+
 import org.hibernate.validation.constraints.NotEmpty;
-import org.hibernate.validation.constraints.NotNull;
 
 /**
  * @author Hardy Ferentschik

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Author.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Author.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Author.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -17,9 +17,10 @@
 */
 package org.hibernate.validation.eg;
 
+import javax.validation.constraints.NotNull;
+
 import org.hibernate.validation.constraints.Length;
 import org.hibernate.validation.constraints.NotEmpty;
-import org.hibernate.validation.constraints.NotNull;
 
 /**
  * @author Hardy Ferentschik

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Book.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Book.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Book.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -19,10 +19,10 @@
 
 import javax.validation.GroupSequence;
 import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
 
 import org.hibernate.validation.constraints.Length;
 import org.hibernate.validation.constraints.NotEmpty;
-import org.hibernate.validation.constraints.NotNull;
 
 /**
  * @author Hardy Ferentschik

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Boy.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Boy.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Boy.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -17,8 +17,9 @@
 */
 package org.hibernate.validation.eg;
 
-import org.hibernate.validation.constraints.NotNull;
+import javax.validation.constraints.NotNull;
 
+
 /**
  * @author Hardy Ferentschik
  */

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Dictonary.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Dictonary.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Dictonary.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -19,9 +19,9 @@
 
 import javax.validation.GroupSequence;
 import javax.validation.GroupSequences;
+import javax.validation.constraints.NotNull;
 
 import org.hibernate.validation.constraints.NotEmpty;
-import org.hibernate.validation.constraints.NotNull;
 
 /**
  * @author Hardy Ferentschik

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Order.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Order.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Order.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -17,7 +17,7 @@
 */
 package org.hibernate.validation.eg;
 
-import org.hibernate.validation.constraints.NotNull;
+import javax.validation.constraints.NotNull;
 
 /**
  * @author Hardy Ferentschik

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Person.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Person.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Person.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -17,8 +17,9 @@
 */
 package org.hibernate.validation.eg;
 
+import javax.validation.constraints.NotNull;
+
 import org.hibernate.validation.constraints.NotEmpty;
-import org.hibernate.validation.constraints.NotNull;
 
 /**
  * @author Hardy Ferentschik

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/impl/ResourceBundleMessageResolverTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/impl/ResourceBundleMessageResolverTest.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/impl/ResourceBundleMessageResolverTest.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -24,16 +24,14 @@
 import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.ResourceBundle;
+import javax.validation.constraints.NotNull;
 
 import static org.junit.Assert.assertEquals;
 import org.junit.Before;
 import org.junit.Test;
-import org.slf4j.Logger;
 
 import org.hibernate.validation.constraints.Length;
-import org.hibernate.validation.constraints.NotNull;
 import org.hibernate.validation.constraints.NotNullConstraint;
-import org.hibernate.validation.util.LoggerFactory;
 
 /**
  * Tests for message resolution.
@@ -41,7 +39,6 @@
  * @author Hardy Ferentschik
  */
 public class ResourceBundleMessageResolverTest {
-	private static final Logger log = LoggerFactory.make();
 
 	private ResourceBundleMessageResolver resolver;
 	private NotNull notNull;

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ReflectionHelperTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ReflectionHelperTest.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ReflectionHelperTest.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -17,16 +17,24 @@
 */
 package org.hibernate.validation.util;
 
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
-import java.util.List;
-import java.util.ArrayList;
+import javax.validation.ValidationException;
+import javax.validation.constraints.NotNull;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import org.junit.Test;
 
 /**
+ * Tests for the <code>ReflectionHelper</code>.
+ *
  * @author Hardy Ferentschik
  */
 public class ReflectionHelperTest {
@@ -41,14 +49,14 @@
 		assertEquals( "We should be able to retrieve the indexed object", testObject, value );
 
 		// try to get to the value by integer index
-	    value = ReflectionHelper.getIndexedValue( map, "0" );
+		value = ReflectionHelper.getIndexedValue( map, "0" );
 		assertEquals( "We should be able to retrieve the indexed object", testObject, value );
 
 		value = ReflectionHelper.getIndexedValue( map, "foo" );
-		assertNull("A non existent index should return the null value", value);
+		assertNull( "A non existent index should return the null value", value );
 
 		value = ReflectionHelper.getIndexedValue( map, "2" );
-		assertNull("A non existent index should return the null value", value);
+		assertNull( "A non existent index should return the null value", value );
 	}
 
 	@Test
@@ -61,7 +69,7 @@
 		assertEquals( "We should be able to retrieve the indexed object", testObject, value );
 
 		value = ReflectionHelper.getIndexedValue( list, "2" );
-		assertNull("A non existent index should return the null value", value);
+		assertNull( "A non existent index should return the null value", value );
 	}
 
 	@Test
@@ -69,4 +77,42 @@
 		Object value = ReflectionHelper.getIndexedValue( null, "0" );
 		assertNull( value );
 	}
+
+	@Test
+	public void testGetMessageParamter() {
+		NotNull testAnnotation = new NotNull() {
+			public String message() {
+				return "test";
+			}
+
+			public String[] groups() {
+				return new String[] { "default" };
+			}
+
+			public Class<? extends Annotation> annotationType() {
+				return this.getClass();
+			}
+		};
+		String message = ReflectionHelper.getAnnotationParameter( testAnnotation, "message", String.class );
+		assertEquals( "Wrong message", "test", message );
+
+		String[] group = ReflectionHelper.getAnnotationParameter( testAnnotation, "groups", String[].class );
+		assertEquals( "Wrong message", "default", group[0] );
+
+		try {
+			ReflectionHelper.getAnnotationParameter( testAnnotation, "message", Integer.class );
+			fail();
+		}
+		catch ( ValidationException e ) {
+			assertTrue( "Wrong exception message", e.getMessage().startsWith( "Wrong parameter type." ) );
+		}
+
+		try {
+			ReflectionHelper.getAnnotationParameter( testAnnotation, "foo", Integer.class );
+			fail();
+		}
+		catch ( ValidationException e ) {
+			assertTrue( "Wrong exception message", e.getMessage().startsWith( "The specified annotation defines no parameter" ) );
+		}
+	}
 }

Modified: validator/trunk/validation-api/src/main/java/javax/validation/ConstraintFactory.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/ConstraintFactory.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/validation-api/src/main/java/javax/validation/ConstraintFactory.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -18,8 +18,8 @@
 package javax.validation;
 
 /**
- * Instantiate a Constraint from it's class.
- * The ConstraintFactory is <b>not</b> responsible for calling Constraint#initialize
+ * 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)}.
  *
  * @author Dhanji R. Prasanna
  * @author Emmanuel Bernard

Modified: validator/trunk/validation-api/src/main/java/javax/validation/constraints/AssertFalse.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/constraints/AssertFalse.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/validation-api/src/main/java/javax/validation/constraints/AssertFalse.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -1,25 +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 javax.validation.constraints;
 
-import java.lang.annotation.Target;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
 import java.lang.annotation.Retention;
-import java.lang.annotation.Documented;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import java.lang.annotation.Target;
 
 /**
  * The annotated element must be false.
  * Supported types are <code>boolean</code> and <code>Boolean</code>
+ * <p/>
+ * <code>null</code> elements are considered valid.
  *
- * Null elements are considered valid
- *
  * @author Emmanuel Bernard
  */
 @Target({ METHOD, FIELD, ANNOTATION_TYPE })
 @Retention(RUNTIME)
 @Documented
 public @interface AssertFalse {
-	String message() default "{constraint.assertFalse}";
-	String[] groups() default {};
+	String message() default "{validator.assertFalse}";
+
+	String[] groups() default { };
 }
\ No newline at end of file

Modified: validator/trunk/validation-api/src/main/java/javax/validation/constraints/AssertTrue.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/constraints/AssertTrue.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/validation-api/src/main/java/javax/validation/constraints/AssertTrue.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -1,25 +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 javax.validation.constraints;
 
-import java.lang.annotation.Target;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
 import java.lang.annotation.Retention;
-import java.lang.annotation.Documented;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import java.lang.annotation.Target;
 
 /**
  * The annotated element must be true.
- * Supported types are <code>boolean</code> and <code>Boolean</code> 
+ * Supported types are <code>boolean</code> and <code>Boolean</code>
+ * <p/>
+ * <code>null</code> elements are considered valid.
  *
- * Null elements are considered valid
- *
  * @author Emmanuel Bernard
  */
 @Target({ METHOD, FIELD, ANNOTATION_TYPE })
 @Retention(RUNTIME)
 @Documented
 public @interface AssertTrue {
-	String message() default "{constraint.assertTrue}";
-	String[] groups() default {};
+	String message() default "{validator.assertTrue}";
+
+	String[] groups() default { };
 }
\ No newline at end of file

Modified: validator/trunk/validation-api/src/main/java/javax/validation/constraints/Digits.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/constraints/Digits.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/validation-api/src/main/java/javax/validation/constraints/Digits.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -1,34 +1,55 @@
+// $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.constraints;
 
-import java.lang.annotation.Target;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
 import java.lang.annotation.Retention;
-import java.lang.annotation.Documented;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import java.lang.annotation.Target;
 
 /**
  * The annotated element must be a number within accepted range
  * Supported types are:
- *   - <code>BigDecimal</code>
- *   - <code>BigInteger</code>
- *   - <code>Number</code>
- *   - <code>String</code> (TODO should we keep it?)
- *   - <code>short</code>, <code>int</code>, <code>long</code>, <code>float</code>, <code>double</code>
- * TODO <code>byte</code>  
+ * <ul>
+ * <li><code>BigDecimal</code></li>
+ * <li><code>BigInteger</code></li>
+ * <li><code>Number</code></li>
+ * <li><code>String</code></li>
+ * <li><code>short</code>, <code>int</code>, <code>long</code>, <code>float</code>, <code>double</code></li>
+ * </ul>
+ * <p/>
+ * <code>null</code> elements are considered valid
  *
- * Null elements are considered valid
- *
  * @author Emmanuel Bernard
+ * @todo support byte ?!
+ * @todo Is string supported or not?
  */
 @Target({ METHOD, FIELD, ANNOTATION_TYPE })
 @Retention(RUNTIME)
 @Documented
 public @interface Digits {
-	String message() default "{constraint.digits}";
-	String[] groups() default {};
+	String message() default "{validator.digits}";
 
+	String[] groups() default { };
+
 	/**
 	 * @return maximum number of integral digits accepted for this number
 	 */

Modified: validator/trunk/validation-api/src/main/java/javax/validation/constraints/Future.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/constraints/Future.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/validation-api/src/main/java/javax/validation/constraints/Future.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -1,34 +1,54 @@
+// $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.constraints;
 
-import java.lang.annotation.Target;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
 import java.lang.annotation.Retention;
-import java.lang.annotation.Documented;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import java.lang.annotation.Target;
 
 /**
  * The annotated element must be a date in the future.
  * Now is defined as the current time according to the virtual machine
  * The calendar used if the compared type is of type <code>Calendar</code>
  * is the calendar based on the current timezone and the current locale.
- *
+ * <p/>
  * TODO what are the implications
- *
+ * <p/>
  * Supported types are:
- *  - <code>java.util.Date</code>
- *  - <code>java.util.Calendar</code>
- *  - TODO new date/time JSR types?
+ * <ul>
+ * <li><code>java.util.Date</code></li>
+ * <li><code>java.util.Calendar</code></li>
+ * </ul>
+ * - TODO new date/time JSR types?
+ * <p/>
+ * <code>null</code> elements are considered valid.
  *
- * Null elements are considered valid
- *
  * @author Emmanuel Bernard
  */
 @Target({ METHOD, FIELD, ANNOTATION_TYPE })
 @Retention(RUNTIME)
 @Documented
 public @interface Future {
-	String message() default "{constraint.future}";
-	String[] groups() default {};
+	String message() default "{validator.future}";
+
+	String[] groups() default { };
 }
\ No newline at end of file

Modified: validator/trunk/validation-api/src/main/java/javax/validation/constraints/Max.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/constraints/Max.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/validation-api/src/main/java/javax/validation/constraints/Max.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -1,36 +1,57 @@
+// $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.constraints;
 
-import java.lang.annotation.Target;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
 import java.lang.annotation.Retention;
-import java.lang.annotation.Documented;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import java.lang.annotation.Target;
 
 /**
  * The annotated element must be a number whose value must be lower or
  * equal than the specificed maximum.
- *
+ * <p/>
  * Supported types are:
- *   - <code>BigDecimal</code>
- *   - <code>BigInteger</code>
- *   - <code>Number</code>
- *   - <code>String</code> (TODO should we keep it?)
- *   - <code>short</code>, <code>int</code>, <code>long</code>, <code>float</code>, <code>double</code>
- * TODO <code>byte</code>
+ * <ul>
+ * <li><code>BigDecimal</code></li>
+ * <li><code>BigInteger</code></li>
+ * <li><code>Number</code></li>
+ * <li><code>String</code></li>
+ * <li><code>short</code>, <code>int</code>, <code>long</code>, <code>float</code>, <code>double</code></li>
+ * </ul>
+ * <p/>
+ * <code>null</code> elements are considered valid
  *
- * Null elements are considered valid
- *
  * @author Emmanuel Bernard
+ * @todo support byte ?!
+ * @todo Is string supported or not?
  */
 @Target({ METHOD, FIELD, ANNOTATION_TYPE })
 @Retention(RUNTIME)
 @Documented
 public @interface Max {
-	String message() default "{constraint.max}";
-	String[] groups() default {};
+	String message() default "{validator.max}";
 
+	String[] groups() default { };
+
 	/**
 	 * @return Value the element must be lower or equal to
 	 */

Modified: validator/trunk/validation-api/src/main/java/javax/validation/constraints/Min.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/constraints/Min.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/validation-api/src/main/java/javax/validation/constraints/Min.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -1,36 +1,57 @@
+// $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.constraints;
 
-import java.lang.annotation.Target;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
 import java.lang.annotation.Retention;
-import java.lang.annotation.Documented;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import java.lang.annotation.Target;
 
 /**
  * The annotated element must be a number whose value must be greater or
  * equal than the specificed minimum
- * 
+ * <p/>
  * Supported types are:
- *   - <code>BigDecimal</code>
- *   - <code>BigInteger</code>
- *   - <code>Number</code>
- *   - <code>String</code> (TODO should we keep it?)
- *   - <code>short</code>, <code>int</code>, <code>long</code>, <code>float</code>, <code>double</code>
- * TODO <code>byte</code>
+ * <ul>
+ * <li><code>BigDecimal</code></li>
+ * <li><code>BigInteger</code></li>
+ * <li><code>Number</code></li>
+ * <li><code>String</code></li>
+ * <li><code>short</code>, <code>int</code>, <code>long</code>, <code>float</code>, <code>double</code></li>
+ * </ul>
+ * <p/>
+ * <code>null</code> elements are considered valid
  *
- * Null elements are considered valid
- *
  * @author Emmanuel Bernard
+ * @todo support byte ?!
+ * @todo Is string supported or not?
  */
 @Target({ METHOD, FIELD, ANNOTATION_TYPE })
 @Retention(RUNTIME)
 @Documented
 public @interface Min {
-	String message() default "{constraint.min}";
-	String[] groups() default {};
+	String message() default "{validator.min}";
 
+	String[] groups() default { };
+
 	/**
 	 * @return Value the element must be higher or equal to
 	 */

Modified: validator/trunk/validation-api/src/main/java/javax/validation/constraints/NotNull.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/constraints/NotNull.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/validation-api/src/main/java/javax/validation/constraints/NotNull.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -1,15 +1,32 @@
+// $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.constraints;
 
-import java.lang.annotation.Target;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
 import java.lang.annotation.Retention;
-import java.lang.annotation.Documented;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import java.lang.annotation.Target;
 
 /**
- * The annotated element must not be null.
+ * The annotated element must not be <code>null</code>.
  * Accepts any type.
  *
  * @author Emmanuel Bernard
@@ -18,6 +35,7 @@
 @Retention(RUNTIME)
 @Documented
 public @interface NotNull {
-	String message() default "{constraint.notNull}";
-	String[] groups() default {};
+	String message() default "{validator.notNull}";
+
+	String[] groups() default { };
 }

Modified: validator/trunk/validation-api/src/main/java/javax/validation/constraints/Null.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/constraints/Null.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/validation-api/src/main/java/javax/validation/constraints/Null.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -1,16 +1,33 @@
+// $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.constraints;
 
-import java.lang.annotation.Target;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
 import java.lang.annotation.Retention;
-import java.lang.annotation.Documented;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import java.lang.annotation.Target;
 
 /**
  * The annotated element must be null.
- * Accepts any type. 
+ * Accepts any type.
  *
  * @author Emmanuel Bernard
  */
@@ -18,7 +35,8 @@
 @Retention(RUNTIME)
 @Documented
 public @interface Null {
-	String message() default "{constraint.null}";
-	String[] groups() default {};
+	String message() default "{validator.null}";
+
+	String[] groups() default { };
 }
 

Modified: validator/trunk/validation-api/src/main/java/javax/validation/constraints/Past.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/constraints/Past.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/validation-api/src/main/java/javax/validation/constraints/Past.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -1,34 +1,54 @@
+// $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.constraints;
 
-import java.lang.annotation.Target;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
 import java.lang.annotation.Retention;
-import java.lang.annotation.Documented;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import java.lang.annotation.Target;
 
 /**
  * The annotated element must be a date in the past.
  * Now is defined as the current time according to the virtual machine
  * The calendar used if the compared type is of type <code>Calendar</code>
  * is the calendar based on the current timezone and the current locale.
- *
+ * <p/>
  * TODO what are the implications
- * 
+ * <p/>
  * Supported types are:
- *  - <code>java.util.Date</code>
- *  - <code>java.util.Calendar</code>
- *  - TODO new date/time JSR types?
+ * <ul>
+ * <li><code>java.util.Date</code></li>
+ * <li><code>java.util.Calendar</code></li>
+ * </ul>
+ * - TODO new date/time JSR types?
+ * <p/>
+ * <code>null</code> elements are considered valid.
  *
- * Null elements are considered valid
- *
  * @author Emmanuel Bernard
  */
 @Target({ METHOD, FIELD, ANNOTATION_TYPE })
 @Retention(RUNTIME)
 @Documented
 public @interface Past {
-	String message() default "{constraint.past}";
-	String[] groups() default {};
+	String message() default "{validator.past}";
+
+	String[] groups() default { };
 }
\ No newline at end of file

Modified: validator/trunk/validation-api/src/main/java/javax/validation/constraints/Size.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/constraints/Size.java	2008-10-23 14:42:43 UTC (rev 15382)
+++ validator/trunk/validation-api/src/main/java/javax/validation/constraints/Size.java	2008-10-23 15:48:18 UTC (rev 15383)
@@ -1,3 +1,20 @@
+// $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.constraints;
 
 import java.lang.annotation.Target;
@@ -12,11 +29,12 @@
  * The annotated element size must be between the specified boundaries (included).
  *
  * Supported types are:
- *   - <code>String</code> (string length is evaludated)
- *   - <code>Collection</code> (collection size is evaluated)
- *   - Array (array length is evaludated)
+ * <ul>
+ * <li><code>String</code> (string length is evaludated)</li>
+ * <li><code>Collection</code> (collection size is evaluated)</li>
+ * <li>Array (array length is evaludated)</li>
  *
- * Null elements are considered valid
+ * <code>null</code> elements are considered valid.
  *
  * @author Emmanuel Bernard
  */
@@ -24,7 +42,7 @@
 @Retention(RUNTIME)
 @Documented
 public @interface Size {
-	String message() default "{constraint.min}";
+	String message() default "{validator.min}";
 	String[] groups() default {};
 
 	/**




More information about the hibernate-commits mailing list