[hibernate-commits] Hibernate SVN: r15853 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Mon Feb 2 10:42:10 EST 2009


Author: hardy.ferentschik
Date: 2009-02-02 10:42:10 -0500 (Mon, 02 Feb 2009)
New Revision: 15853

Added:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullValidator.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NullValidator.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastValidatorForCalendar.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastValidatorForDate.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidator.java
Removed:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullConstraintValidator.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NullConstraintValidator.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastConstraintCalendarValidator.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastConstraintDateValidator.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeConstraintValidator.java
Log:
Renamed classes to have a consistent naming scheme

Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullConstraintValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullConstraintValidator.java	2009-02-02 15:41:31 UTC (rev 15852)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullConstraintValidator.java	2009-02-02 15:42:10 UTC (rev 15853)
@@ -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.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, Object> {
-
-	public void initialize(NotNull parameters) {
-	}
-
-	public boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext) {
-		return object != null;
-	}
-}

Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullValidator.java (from rev 15848, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullConstraintValidator.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullValidator.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullValidator.java	2009-02-02 15:42:10 UTC (rev 15853)
@@ -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 NotNullValidator implements ConstraintValidator<NotNull, Object> {
+
+	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/NotNullValidator.java
___________________________________________________________________
Name: svn:keywords
   + Id

Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NullConstraintValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NullConstraintValidator.java	2009-02-02 15:41:31 UTC (rev 15852)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NullConstraintValidator.java	2009-02-02 15:42:10 UTC (rev 15853)
@@ -1,38 +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.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.constraints.Null;
-
-/**
- * Validate that the object is <code>null</code>
- *
- * @author Alaa Nassef
- */
-public class NullConstraintValidator implements ConstraintValidator<Null, Object> {
-
-	public void initialize(Null constraintAnnotation) {
-	}
-
-	public boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext) {
-		return object == null;
-	}
-
-}

Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NullValidator.java (from rev 15848, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NullConstraintValidator.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NullValidator.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NullValidator.java	2009-02-02 15:42:10 UTC (rev 15853)
@@ -0,0 +1,38 @@
+// $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.Null;
+
+/**
+ * Validate that the object is <code>null</code>
+ *
+ * @author Alaa Nassef
+ */
+public class NullValidator implements ConstraintValidator<Null, Object> {
+
+	public void initialize(Null constraintAnnotation) {
+	}
+
+	public boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext) {
+		return object == null;
+	}
+
+}


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

Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastConstraintCalendarValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastConstraintCalendarValidator.java	2009-02-02 15:41:31 UTC (rev 15852)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastConstraintCalendarValidator.java	2009-02-02 15:42:10 UTC (rev 15853)
@@ -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 java.util.Calendar;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.constraints.Past;
-
-/**
- * Check that the <code>java.util.Calendar</code> passed to be validated is in the
- * past.
- *
- * @author Alaa Nassef
- */
-public class PastConstraintCalendarValidator implements ConstraintValidator<Past, Calendar> {
-
-	public void initialize(Past constraintAnnotation) {
-	}
-
-	public boolean isValid(Calendar cal, ConstraintValidatorContext constraintValidatorContext) {
-		//null values are valid
-		if ( cal == null ) {
-			return true;
-		}
-		return cal.before( Calendar.getInstance() );
-	}
-}

Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastConstraintDateValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastConstraintDateValidator.java	2009-02-02 15:41:31 UTC (rev 15852)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastConstraintDateValidator.java	2009-02-02 15:42:10 UTC (rev 15853)
@@ -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 java.util.Date;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.constraints.Past;
-
-/**
- * Check that the <code>java.util.Date</code> passed to be validated is in the
- * past.
- *
- * @author Alaa Nassef
- */
-public class PastConstraintDateValidator implements ConstraintValidator<Past, Date> {
-
-	public void initialize(Past constraintAnnotation) {
-	}
-
-	public boolean isValid(Date date, ConstraintValidatorContext constraintValidatorContext) {
-		//null values are valid
-		if ( date == null ) {
-			return true;
-		}
-		return date.before( new Date() );
-	}
-}

Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastValidatorForCalendar.java (from rev 15848, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastConstraintCalendarValidator.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastValidatorForCalendar.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastValidatorForCalendar.java	2009-02-02 15:42:10 UTC (rev 15853)
@@ -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 java.util.Calendar;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Past;
+
+/**
+ * Check that the <code>java.util.Calendar</code> passed to be validated is in the
+ * past.
+ *
+ * @author Alaa Nassef
+ */
+public class PastValidatorForCalendar implements ConstraintValidator<Past, Calendar> {
+
+	public void initialize(Past constraintAnnotation) {
+	}
+
+	public boolean isValid(Calendar cal, ConstraintValidatorContext constraintValidatorContext) {
+		//null values are valid
+		if ( cal == null ) {
+			return true;
+		}
+		return cal.before( Calendar.getInstance() );
+	}
+}


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

Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastValidatorForDate.java (from rev 15848, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastConstraintDateValidator.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastValidatorForDate.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastValidatorForDate.java	2009-02-02 15:42:10 UTC (rev 15853)
@@ -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 java.util.Date;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Past;
+
+/**
+ * Check that the <code>java.util.Date</code> passed to be validated is in the
+ * past.
+ *
+ * @author Alaa Nassef
+ */
+public class PastValidatorForDate implements ConstraintValidator<Past, Date> {
+
+	public void initialize(Past constraintAnnotation) {
+	}
+
+	public boolean isValid(Date date, ConstraintValidatorContext constraintValidatorContext) {
+		//null values are valid
+		if ( date == null ) {
+			return true;
+		}
+		return date.before( new Date() );
+	}
+}


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

Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeConstraintValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeConstraintValidator.java	2009-02-02 15:41:31 UTC (rev 15852)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeConstraintValidator.java	2009-02-02 15:42:10 UTC (rev 15853)
@@ -1,68 +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.reflect.Array;
-import java.util.Collection;
-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
- */
-//FIXME split into several type-safe validators
-public class SizeConstraintValidator implements ConstraintValidator<Size, Object> {
-	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;
-	}
-}

Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidator.java (from rev 15848, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeConstraintValidator.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidator.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidator.java	2009-02-02 15:42:10 UTC (rev 15853)
@@ -0,0 +1,68 @@
+// $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.reflect.Array;
+import java.util.Collection;
+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
+ */
+//FIXME split into several type-safe validators
+public class SizeValidator implements ConstraintValidator<Size, Object> {
+	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/SizeValidator.java
___________________________________________________________________
Name: svn:keywords
   + Id




More information about the hibernate-commits mailing list