[lang][patch] Validate.java: fixes comment skew, removes unused loop counter.
Submitted by:	Janek Bogucki
Reviewed by:	Gary Gregory


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137775 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2004-02-11 23:33:23 +00:00
parent 7c1dda3e75
commit cb9f2a2175
1 changed files with 22 additions and 14 deletions

View File

@ -72,7 +72,7 @@ import java.util.Map;
* @author Stephen Colebourne * @author Stephen Colebourne
* @author Gary Gregory * @author Gary Gregory
* @since 2.0 * @since 2.0
* @version $Id: Validate.java,v 1.7 2004/01/19 23:24:07 fredrik Exp $ * @version $Id: Validate.java,v 1.8 2004/02/11 23:33:23 ggregory Exp $
*/ */
public class Validate { public class Validate {
@ -124,7 +124,7 @@ public class Validate {
* Validate.isTrue( i > 0, "The value must be greater than zero: ", i); * Validate.isTrue( i > 0, "The value must be greater than zero: ", i);
* </pre> * </pre>
* *
* <p>For performance reasons, the object is passed as a separate parameter and * <p>For performance reasons, the long value is passed as a separate parameter and
* appended to the message string only in the case of an error.</p> * appended to the message string only in the case of an error.</p>
* *
* @param expression a boolean expression * @param expression a boolean expression
@ -150,7 +150,7 @@ public class Validate {
* Validate.isTrue( d > 0.0, "The value must be greater than zero: ", d); * Validate.isTrue( d > 0.0, "The value must be greater than zero: ", d);
* </pre> * </pre>
* *
* <p>For performance reasons, the object is passed as a separate parameter and * <p>For performance reasons, the double value is passed as a separate parameter and
* appended to the message string only in the case of an error.</p> * appended to the message string only in the case of an error.</p>
* *
* @param expression a boolean expression * @param expression a boolean expression
@ -345,7 +345,7 @@ public class Validate {
* if the argument Map is empty (<code>null</code> or no elements).</p> * if the argument Map is empty (<code>null</code> or no elements).</p>
* *
* <pre> * <pre>
* Validate.notEmpty(myMap, "The collection must not be empty"); * Validate.notEmpty(myMap, "The map must not be empty");
* </pre> * </pre>
* *
* @param map the map to check is not empty * @param map the map to check is not empty
@ -426,9 +426,11 @@ public class Validate {
* <code>null</code>.</p> * <code>null</code>.</p>
* *
* <pre> * <pre>
* Validate.notEmpty(myArray, "The array must not contain null elements"); * Validate.noNullElements(myArray, "The array must not contain null elements");
* </pre> * </pre>
* *
* <p>If the array is null then the message in the exception is 'The validated object is null'.</p>
*
* @param array the array to check * @param array the array to check
* @param message the exception message if the array has * @param message the exception message if the array has
* <code>null</code> elements * <code>null</code> elements
@ -450,10 +452,13 @@ public class Validate {
* <code>null</code>.</p> * <code>null</code>.</p>
* *
* <pre> * <pre>
* Validate.notEmpty(myArray); * Validate.noNullElements(myArray);
* </pre> * </pre>
* *
* <p>The message in the exception is 'The validated array contains null element at index: '.</p> * <p>If the array has a null element the message in the exception is
* 'The validated array contains null element at index: '.</p>
*
* <p>If the array is null then the message in the exception is 'The validated object is null'.</p>
* *
* @param array the array to check * @param array the array to check
* @throws IllegalArgumentException if the array has <code>null</code> * @throws IllegalArgumentException if the array has <code>null</code>
@ -473,23 +478,24 @@ public class Validate {
/** /**
* <p>Validate an argument, throwing <code>IllegalArgumentException</code> * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
* if the argument collection has <code>null</code> elements or is * if the argument Collection has <code>null</code> elements or is
* <code>null</code>.</p> * <code>null</code>.</p>
* *
* <pre> * <pre>
* Validate.notEmpty(myCollection, "The collection must not contain null elements"); * Validate.noNullElements(myCollection, "The collection must not contain null elements");
* </pre> * </pre>
* *
* <p>If the collection is null then the message in the exception is 'The validated object is null'.</p>
*
* @param collection the collection to check * @param collection the collection to check
* @param message the exception message if the array has * @param message the exception message if the collection has
* <code>null</code> elements * <code>null</code> elements
* @throws IllegalArgumentException if the collection has * @throws IllegalArgumentException if the collection has
* <code>null</code> elements or is <code>null</code> * <code>null</code> elements or is <code>null</code>
*/ */
public static void noNullElements(Collection collection, String message) { public static void noNullElements(Collection collection, String message) {
Validate.notNull(collection); Validate.notNull(collection);
int i = 0; for (Iterator it = collection.iterator(); it.hasNext();) {
for (Iterator it = collection.iterator(); it.hasNext(); i++) {
if (it.next() == null) { if (it.next() == null) {
throw new IllegalArgumentException(message); throw new IllegalArgumentException(message);
} }
@ -498,15 +504,17 @@ public class Validate {
/** /**
* <p>Validate an argument, throwing <code>IllegalArgumentException</code> * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
* if the argument collection has <code>null</code> elements or is * if the argument Collection has <code>null</code> elements or is
* <code>null</code>.</p> * <code>null</code>.</p>
* *
* <pre> * <pre>
* Validate.notEmpty(myCollection); * Validate.noNullElements(myCollection);
* </pre> * </pre>
* *
* <p>The message in the exception is 'The validated collection contains null element at index: '.</p> * <p>The message in the exception is 'The validated collection contains null element at index: '.</p>
* *
* <p>If the collection is null then the message in the exception is 'The validated object is null'.</p>
*
* @param collection the collection to check * @param collection the collection to check
* @throws IllegalArgumentException if the collection has * @throws IllegalArgumentException if the collection has
* <code>null</code> elements or is <code>null</code> * <code>null</code> elements or is <code>null</code>