Java org.apache.commons.lang Validate fields, constructors, methods, implement or subclass

Example usage for Java org.apache.commons.lang Validate fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for org.apache.commons.lang Validate.

The text is from its open source code.

Subclass

org.apache.commons.lang.Validate has subclasses.
Click this link to see all its subclasses.

Method

voidallElementsOfType(Collection collection, Class clazz)

Validate an argument, throwing IllegalArgumentException if the argument collection is null or has elements that are not of type clazz or a subclass.

voidallElementsOfType(Collection collection, Class clazz, String message)

Validate an argument, throwing IllegalArgumentException if the argument collection is null or has elements that are not of type clazz or a subclass.

 Validate.allElementsOfType(collection, String.class, "Collection has invalid elements"); 
voidisTrue(boolean expression)

Validate an argument, throwing IllegalArgumentException if the test result is false.

This is used when validating according to an arbitrary boolean expression, such as validating a primitive number or using your own custom validation expression.

 Validate.isTrue( i > 0 ); Validate.isTrue( myObject.isOk() ); 

The message in the exception is 'The validated expression is false'.

voidisTrue(boolean expression, String message)

Validate an argument, throwing IllegalArgumentException if the test result is false.

This is used when validating according to an arbitrary boolean expression, such as validating a primitive number or using your own custom validation expression.

 Validate.isTrue( (i > 0), "The value must be greater than zero"); Validate.isTrue( myObject.isOk(), "The object is not OK"); 

For performance reasons, the message string should not involve a string append, instead use the #isTrue(boolean,String,Object) method.

voidisTrue(boolean expression, String message, Object value)

Validate an argument, throwing IllegalArgumentException if the test result is false.

This is used when validating according to an arbitrary boolean expression, such as validating a primitive number or using your own custom validation expression.

 Validate.isTrue( myObject.isOk(), "The object is not OK: ", myObject); 

For performance reasons, the object is passed as a separate parameter and appended to the message string only in the case of an error.

voidisTrue(boolean expression, String message, long value)

Validate an argument, throwing IllegalArgumentException if the test result is false.

This is used when validating according to an arbitrary boolean expression, such as validating a primitive number or using your own custom validation expression.

 Validate.isTrue( i > 0, "The value must be greater than zero: ", i); 

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.

voidisTrue(boolean expression, String message, double value)

Validate an argument, throwing IllegalArgumentException if the test result is false.

This is used when validating according to an arbitrary boolean expression, such as validating a primitive number or using your own custom validation expression.

 Validate.isTrue( d > 0.0, "The value must be greater than zero: ", d); 

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.

voidnoNullElements(Object[] array, String message)

Validate an argument, throwing IllegalArgumentException if the argument array has null elements or is null.

 Validate.noNullElements(myArray, "The array must not contain null elements"); 

If the array is null then the message in the exception is 'The validated object is null'.

voidnoNullElements(Collection collection, String message)

Validate an argument, throwing IllegalArgumentException if the argument Collection has null elements or is null.

 Validate.noNullElements(myCollection, "The collection must not contain null elements"); 

If the collection is null then the message in the exception is 'The validated object is null'.

voidnoNullElements(Object[] array)

Validate an argument, throwing IllegalArgumentException if the argument array has null elements or is null.

 Validate.noNullElements(myArray); 

If the array has a null element the message in the exception is 'The validated array contains null element at index: '.

If the array is null then the message in the exception is 'The validated object is null'.

voidnoNullElements(Collection collection)

Validate an argument, throwing IllegalArgumentException if the argument Collection has null elements or is null.

 Validate.noNullElements(myCollection); 

The message in the exception is 'The validated collection contains null element at index: '.

If the collection is null then the message in the exception is 'The validated object is null'.

voidnotEmpty(Object[] array, String message)

Validate an argument, throwing IllegalArgumentException if the argument array is empty (null or no elements).

 Validate.notEmpty(myArray, "The array must not be empty"); 
voidnotEmpty(Collection collection, String message)

Validate an argument, throwing IllegalArgumentException if the argument Collection is empty (null or no elements).

 Validate.notEmpty(myCollection, "The collection must not be empty"); 
voidnotEmpty(Map map, String message)

Validate an argument, throwing IllegalArgumentException if the argument Map is empty (null or no elements).

 Validate.notEmpty(myMap, "The map must not be empty"); 
voidnotEmpty(String string, String message)

Validate an argument, throwing IllegalArgumentException if the argument String is empty (null or zero length).

 Validate.notEmpty(myString, "The string must not be empty"); 
voidnotEmpty(Object[] array)

Validate an argument, throwing IllegalArgumentException if the argument array is empty (null or no elements).

 Validate.notEmpty(myArray); 

The message in the exception is 'The validated array is empty'.

voidnotEmpty(Collection collection)

Validate an argument, throwing IllegalArgumentException if the argument Collection is empty (null or no elements).

 Validate.notEmpty(myCollection); 

The message in the exception is 'The validated collection is empty'.

voidnotEmpty(Map map)

Validate an argument, throwing IllegalArgumentException if the argument Map is empty (null or no elements).

 Validate.notEmpty(myMap); 

The message in the exception is 'The validated map is empty'.

voidnotEmpty(String string)

Validate an argument, throwing IllegalArgumentException if the argument String is empty (null or zero length).

 Validate.notEmpty(myString); 

The message in the exception is 'The validated string is empty'.

voidnotNull(Object object, String message)

Validate an argument, throwing IllegalArgumentException if the argument is null.

 Validate.notNull(myObject, "The object must not be null"); 
voidnotNull(Object object)

Validate an argument, throwing IllegalArgumentException if the argument is null.

 Validate.notNull(myObject); 

The message in the exception is 'The validated object is null'.