Package com.castlabs.utils
Class Validate
java.lang.Object
com.castlabs.utils.Validate
Helper class that can be used to validate input.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic booleanRecursively check the bundles for equalitystatic <T> TinstanceOf(Throwable cause, Class<T> cl) Search for the specific cause recursivelystatic voidValidate that the argument condition istrue; otherwise throwing an exception with the specified message.static voidValidate that the specified argument is notnull; otherwise throwing an exception.static voidValidate that the specified argument is notnull; otherwise throwing an exception with the specified message.
- 
Constructor Details- 
Validatepublic Validate()
 
- 
- 
Method Details- 
notNullValidate that the specified argument is not null; otherwise throwing an exception.Validate.notNull(myObject); The message of the exception is "The validated object is null". - Parameters:
- object- the object to check
- Throws:
- IllegalArgumentException- if the object is- null
 
- 
notNullValidate that the specified argument is not null; otherwise throwing an exception with the specified message.Validate.notNull(myObject, "The object must not be null"); - Parameters:
- object- the object to check
- message- the exception message if invalid
 
- 
isTrueValidate that the argument condition is true; otherwise throwing an exception with the specified message. This method is useful 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");- Parameters:
- expression- the boolean expression to check
- message- the exception message if invalid
- Throws:
- IllegalArgumentException- if expression is- false
 
- 
areEqualRecursively check the bundles for equality - Parameters:
- b1- the Bundle to compare
- b2- the Bundle to compare
- Returns:
- trueif the bundles are identical or- falseotherwise
 
- 
instanceOfSearch for the specific cause recursively- Type Parameters:
- T- Specific cause type to search for
- Parameters:
- cause- Specified container cause
- cl- Specific cause class to search for
- Returns:
- Specific cause instance if it was found in the container cause, otherwise null
 
 
-