[hibernate-commits] Hibernate SVN: r16163 - beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Mon Mar 16 19:50:05 EDT 2009


Author: epbernard
Date: 2009-03-16 19:50:05 -0400 (Mon, 16 Mar 2009)
New Revision: 16163

Added:
   beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/DecimalMax.java
   beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/DecimalMin.java
Modified:
   beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Max.java
   beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Min.java
   beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Size.java
Log:
BVAL-142 Min/@max no longer accept float/double and introduce @DecimalMin/@DecimalMax

Copied: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/DecimalMax.java (from rev 16160, beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Max.java)
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/DecimalMax.java	                        (rev 0)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/DecimalMax.java	2009-03-16 23:50:05 UTC (rev 16163)
@@ -0,0 +1,74 @@
+// $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.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 static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * The annotated element must be a number whose value must be lower or
+ * equal to the specified maximum.
+ * <p/>
+ * Supported types are:
+ * <ul>
+ * <li><code>BigDecimal</code></li>
+ * <li><code>BigInteger</code></li>
+ * <li><code>String</code></li>
+ * <li><code>byte</code>, <code>short</code>, <code>int</code>, <code>long</code>,
+ * and their respective wrappers</li>
+ * </ul>
+ * Note that <code>double</code> and <code>float</code> are not supported due to rounding errors 
+ * (some providers might provide some approximative support)
+ * <p/>
+ * <code>null</code> elements are considered valid
+ *
+ * @author Emmanuel Bernard
+ */
+ at Target({ METHOD, FIELD, ANNOTATION_TYPE })
+ at Retention(RUNTIME)
+ at Documented
+public @interface DecimalMax {
+	String message() default "{constraint.decimalmax}";
+
+	Class<?>[] groups() default { };
+
+	/**
+	 * The String representation of the max value according to the
+	 * BigDecimal string representation
+	 * @return value the element must be lower or equal to
+	 */
+	String value();
+
+	/**
+	 * Defines several @DecimalMax annotations on the same element
+	 * @see {@link DecimalMax}
+	 *
+	 * @author Emmanuel Bernard
+	 */
+	@Target({ METHOD, FIELD, ANNOTATION_TYPE })
+	@Retention(RUNTIME)
+	@Documented
+	@interface List {
+		DecimalMax[] value();
+	}
+}
\ No newline at end of file

Added: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/DecimalMin.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/DecimalMin.java	                        (rev 0)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/DecimalMin.java	2009-03-16 23:50:05 UTC (rev 16163)
@@ -0,0 +1,74 @@
+// $Id: Max.java 16152 2009-03-12 21:33:48Z epbernard $
+/*
+* 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.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 static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * The annotated element must be a number whose value must be higher or
+ * equal to the specificed minimum.
+ * <p/>
+ * Supported types are:
+ * <ul>
+ * <li><code>BigDecimal</code></li>
+ * <li><code>BigInteger</code></li>
+ * <li><code>String</code></li>
+ * <li><code>byte</code>, <code>short</code>, <code>int</code>, <code>long</code>,
+ * and their respective wrappers</li>
+ * </ul>
+ * Note that <code>double</code> and <code>float</code> are not supported due to rounding errors
+ * (some providers might provide some approximative support)
+ * <p/>
+ * <code>null</code> elements are considered valid
+ *
+ * @author Emmanuel Bernard
+ */
+ at Target({ METHOD, FIELD, ANNOTATION_TYPE })
+ at Retention(RUNTIME)
+ at Documented
+public @interface DecimalMin {
+	String message() default "{constraint.decimalmin}";
+
+	Class<?>[] groups() default { };
+
+	/**
+	 * The String representation of the min value according to the
+	 * BigDecimal string representation
+	 * @return value the element must be higher or equal to
+	 */
+	String value();
+
+	/**
+	 * Defines several @DecimalMin annotations on the same element
+	 * @see {@link DecimalMin}
+	 *
+	 * @author Emmanuel Bernard
+	 */
+	@Target({ METHOD, FIELD, ANNOTATION_TYPE })
+	@Retention(RUNTIME)
+	@Documented
+	@interface List {
+		DecimalMin[] value();
+	}
+}
\ No newline at end of file

Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Max.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Max.java	2009-03-16 23:34:13 UTC (rev 16162)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Max.java	2009-03-16 23:50:05 UTC (rev 16163)
@@ -27,22 +27,21 @@
 
 /**
  * The annotated element must be a number whose value must be lower or
- * equal than the specificed maximum.
+ * equal to the specified maximum.
  * <p/>
  * Supported types are:
  * <ul>
  * <li><code>BigDecimal</code></li>
  * <li><code>BigInteger</code></li>
- * <li><code>Number</code></li>
- * <li><code>String</code></li>
  * <li><code>byte</code>, <code>short</code>, <code>int</code>, <code>long</code>, 
- * <code>float</code>, <code>double</code></li>
+ * and their respective wrappers</li>
  * </ul>
+ * Note that <code>double</code> and <code>float</code> are not supported due to rounding errors
+ * (some providers might provide some approximative support)
  * <p/>
  * <code>null</code> elements are considered valid
  *
  * @author Emmanuel Bernard
- * @todo Is string supported or not?
  */
 @Target({ METHOD, FIELD, ANNOTATION_TYPE })
 @Retention(RUNTIME)
@@ -53,13 +52,13 @@
 	Class<?>[] groups() default { };
 
 	/**
-	 * @return Value the element must be lower or equal to
+	 * @return value the element must be lower or equal to
 	 */
 	long value();
 
 	/**
 	 * Defines several @Max annotations on the same element
-	 * @see Max
+	 * @see {@link Max}
 	 *
 	 * @author Emmanuel Bernard
 	 */

Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Min.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Min.java	2009-03-16 23:34:13 UTC (rev 16162)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Min.java	2009-03-16 23:50:05 UTC (rev 16163)
@@ -26,23 +26,22 @@
 import java.lang.annotation.Target;
 
 /**
- * The annotated element must be a number whose value must be greater or
- * equal than the specificed minimum
+ * The annotated element must be a number whose value must be higher or
+ * equal to the specified minimum.
  * <p/>
  * Supported types are:
  * <ul>
  * <li><code>BigDecimal</code></li>
  * <li><code>BigInteger</code></li>
- * <li><code>Number</code></li>
- * <li><code>String</code></li>
  * <li><code>byte</code>, <code>short</code>, <code>int</code>, <code>long</code>,
- * <code>float</code>, <code>double</code></li>
+ * and their respective wrappers</li>
  * </ul>
+ * Note that <code>double</code> and <code>float</code> are not supported due to rounding errors
+ * (some providers might provide some approximative support)
  * <p/>
  * <code>null</code> elements are considered valid
  *
  * @author Emmanuel Bernard
- * @todo Is string supported or not?
  */
 @Target({ METHOD, FIELD, ANNOTATION_TYPE })
 @Retention(RUNTIME)
@@ -53,13 +52,13 @@
 	Class<?>[] groups() default { };
 
 	/**
-	 * @return Value the element must be higher or equal to
+	 * @return value the element must be higher or equal to
 	 */
 	long value();
 
 	/**
 	 * Defines several @Min annotations on the same element
-	 * @see javax.validation.constraints.Min
+	 * @see {@link Min}
 	 *
 	 * @author Emmanuel Bernard
 	 */

Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Size.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Size.java	2009-03-16 23:34:13 UTC (rev 16162)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Size.java	2009-03-16 23:50:05 UTC (rev 16163)
@@ -33,7 +33,7 @@
  * <li><code>String</code> (string length is evaludated)</li>
  * <li><code>Collection</code> (collection size is evaluated)</li>
  * <li><code>Map</code> (map size is evaluated)</li>
- * <li>Array (array length is evaludated)</li>
+ * <li>Array (array length is evaluated)</li>
  *
  * <code>null</code> elements are considered valid.
  *
@@ -58,7 +58,7 @@
 
 	/**
 	 * Defines several @Size annotations on the same element
-	 * @see Size
+	 * @see {@link Size}
 	 *
 	 * @author Emmanuel Bernard
 	 */




More information about the hibernate-commits mailing list