net.sf.staccatocommons.check
Class Check<ExceptionType extends Throwable>

java.lang.Object
  extended by net.sf.staccatocommons.check.Check<ExceptionType>
Type Parameters:
ExceptionType - The kind of exception that this check will thrown on validation failures
Direct Known Subclasses:
Validate

@Transparent
public abstract class Check<ExceptionType extends Throwable>
extends Object

Checks are objects that validate conditions. It is heavily inspired on several validation utilities like org.apache.commons.lang.Validate from Apache commons, but is designed to be more flexible and easy-to-use, so, it should be seen as higher lever replacement. The four main differences are the following

All check methods take a paremeterName as first argument. This is a String identifier of the var being check, that allows to find it in context. For example, if what is being check is a method var or local var, its var name should be used, if is its an an attribute or property is being used, its property name should be used. Checks are Transparent

Author:
flbulgarelli
See Also:
Validate, Ensure, Assert

Nested Class Summary
static class Check.Failure
          A basic check failure
static class Check.VarFailure
          A check failure that contains the name and value of the variable that was checked
 
Constructor Summary
Check()
           
 
Method Summary
<T> Check<ExceptionType>
contains(String varName, ContainsAware<T> var, T element)
          Checks that the variable contains the given element
protected abstract  ExceptionType createException(Check.Failure failure)
           
protected  ExceptionType createVarException(Check.VarFailure failure)
           
<Nothing> Nothing
fail(String message, Object... args)
          Fails, throwing an exception with a message.
<Nothing> Nothing
failVar(String varName, Object var, String message, Object... args)
          Fails, throwing an exception with a message, the var and its name.
<T extends Comparable<T>>
Check<ExceptionType>
isBetween(String varName, T var, T min, T max)
          Checks the var is not null, less than or equal to max and greater than or equal to min
<A> Check<ExceptionType>
isEmpty(String varName, A var, EmptyAwareType<A> type)
          Checks that the variable is not null and empty
 Check<ExceptionType> isEmpty(String varName, CharSequence var)
          Checks that the variable is not null and empty
 Check<ExceptionType> isEmpty(String varName, Collection<?> var)
          Checks that the variable is not null and empty
 Check<ExceptionType> isEmpty(String varName, EmptyAware var)
          Checks that the variable is not null and empty
 Check<ExceptionType> isEmpty(String varName, Iterable<?> var)
          Checks that the variable is not null and empty
 Check<ExceptionType> isEmpty(String varName, Map<?,?> var)
          Checks that the variable is not null and empty
 Check<ExceptionType> isFalse(String varName, boolean var)
          Checks a that the variable is true, failing with a generated message if it is not.
<T extends Comparable<T>>
Check<ExceptionType>
isGreaterThan(String varName, T var, T other)
          Checks that the variable is not null and > than other
<T extends Comparable<T>>
Check<ExceptionType>
isGreaterThanOrEqualTo(String varName, T var, T other)
          Checks that the variable is not null and >= than other
<T> Check<ExceptionType>
isIn(String varName, T var, ContainsAware<T> container)
          Checks the var is not null and contained by the given container
 Check<ExceptionType> isInstanceOf(String varName, Object var, Class<?> expectedClass)
          Checks that the variable is not null and instance of the given class
<T extends Comparable<T>>
Check<ExceptionType>
isLessThan(String varName, T var, T other)
          Checks that the variable is not null and < than other
<T extends Comparable<T>>
Check<ExceptionType>
isLessThanOrEqualTo(String varName, T var, T other)
          Checks that the variable is not null and <= than other
<A> Check<ExceptionType>
isMaxSize(String varName, A var, int maxSize, SizeAwareType<A> type)
          Checks that var is not null and its size less than or equals to the the given maxSize
 Check<ExceptionType> isMaxSize(String varName, Collection<?> var, int minSize)
          Checks that var is not null and its size less than or equals to the the given maxSize
<A> Check<ExceptionType>
isMinSize(String varName, A var, int minSize, SizeAwareType<A> type)
          Checks that var is not null and its size greater than or equals to the the given minSize
 Check<ExceptionType> isMinSize(String varName, Collection<?> var, int minSize)
          Checks that var is not null and its size greater than or equals to the the given minSize
<A> Check<ExceptionType>
isNotEmpty(String varName, A var, EmptyAwareType<A> type)
          Checks that the variable is not null and not empty
 Check<ExceptionType> isNotEmpty(String varName, CharSequence var)
          Checks that the CharSequence variable is not null and not empty
 Check<ExceptionType> isNotEmpty(String varName, Collection<?> var)
          Checks that the Collection variable is not null and not empty
 Check<ExceptionType> isNotEmpty(String varName, EmptyAware var)
          Checks that the EmptyAware var is not null and not empty
 Check<ExceptionType> isNotEmpty(String varName, Iterable<?> var)
          Checks that the Iterable variable is not null and not empty
 Check<ExceptionType> isNotEmpty(String varName, Map<?,?> var)
          Checks that the Map variable is not null and not empty
<A> Check<ExceptionType>
isNotNegative(String varName, A var, NumberType<A> type)
          Checks the var is >= 0
 Check<ExceptionType> isNotNegative(String varName, BigDecimal var)
          Checks the variable is >= 0
 Check<ExceptionType> isNotNegative(String varName, BigInteger var)
          Checks the variable is >= 0
 Check<ExceptionType> isNotNegative(String varName, double var)
          Checks the variable is >= 0
 Check<ExceptionType> isNotNegative(String varName, float var)
          Checks the variable is >= 0
 Check<ExceptionType> isNotNegative(String varName, int var)
          Checks the variable is >= 0
 Check<ExceptionType> isNotNegative(String varName, long var)
          Checks the variable is >= 0
 Check<ExceptionType> isNotNull(String varName, Object var)
          Checks the variable is not null.
<A> Check<ExceptionType>
isNotZero(String varName, A var, NumberType<A> type)
          Checks the var is not null and not equal to 0
 Check<ExceptionType> isNull(String varName, Object var)
          Checks the variable is null.
<A> Check<ExceptionType>
isPositive(String varName, A var, NumberType<A> type)
          Checks the var is > 0
 Check<ExceptionType> isPositive(String varName, BigDecimal var)
          Checks the var is > 0
 Check<ExceptionType> isPositive(String varName, BigInteger var)
          Checks the var is not null and > 0
 Check<ExceptionType> isPositive(String varName, double var)
          Checks the var is > 0
 Check<ExceptionType> isPositive(String varName, float var)
          Checks the var is > 0
 Check<ExceptionType> isPositive(String varName, int var)
          Checks the var is > 0
 Check<ExceptionType> isPositive(String varName, long var)
          Checks the var is > 0
<A> Check<ExceptionType>
isSize(String varName, A var, int expectedSize, SizeAwareType<A> type)
          Checks that var is not null and its ize is the given expectedSize
 Check<ExceptionType> isSize(String varName, CharSequence var, int size)
          Checks that var is not null and its size is the given expectedSize
 Check<ExceptionType> isSize(String varName, Collection<?> var, int size)
          Checks that var is not null and its size is the given expectedSize
 Check<ExceptionType> isSize(String varName, Map<?,?> var, int size)
          Checks that var is not null and its size is the given expectedSize
 Check<ExceptionType> isSize(String varName, SizeAware var, int size)
          Checks that var is not null and its size is the given expectedSize
 Check<ExceptionType> isTrue(String varName, boolean var)
          Checks a that the variable is true, failing with a generated message if it is not.
<A> Check<ExceptionType>
isZero(String varName, A var, NumberType<A> type)
          Checks the var is not null and equal to 0
 Check<ExceptionType> matches(String varName, String var, Pattern pattern)
          Checks that the variable is not null and matches a given pattern
 Check<ExceptionType> matches(String varName, String var, String regex)
          Checks that the variable is not null and matches a given regular expression.
 Check<ExceptionType> that(boolean condition, String message, Object... args)
          Checks a that a condition is true, failing if it is not.
 Check<ExceptionType> thatVar(String varName, Object var, boolean condition, String message, Object... args)
          Checks a condition, failing if not met.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Check

public Check()
Method Detail

createVarException

protected ExceptionType createVarException(Check.VarFailure failure)

createException

protected abstract ExceptionType createException(Check.Failure failure)

fail

public <Nothing> Nothing fail(String message,
                              Object... args)
             throws ExceptionType extends Throwable
Fails, throwing an exception with a message. This method never returns normally.

Type Parameters:
Nothing -
Parameters:
message - the error message
args - the error message args
Returns:
this method does never return normally
Throws:
ExceptionType - always
ExceptionType extends Throwable

failVar

public <Nothing> Nothing failVar(String varName,
                                 Object var,
                                 String message,
                                 Object... args)
                throws ExceptionType extends Throwable
Fails, throwing an exception with a message, the var and its name. This method never returns normally.

Type Parameters:
Nothing -
Parameters:
varName - the name of the variable whose check failed
var - the variable whose check failed
message - the error message
args - the error message arguments
Returns:
this method does never return normally
Throws:
ExceptionType - always
ExceptionType extends Throwable

thatVar

public final Check<ExceptionType> thatVar(String varName,
                                          Object var,
                                          boolean condition,
                                          String message,
                                          Object... args)
                                                     throws ExceptionType extends Throwable
Checks a condition, failing if not met.

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
condition - the condition to be checked
message - the error message
args - the error message arguments
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

that

public final Check<ExceptionType> that(boolean condition,
                                       String message,
                                       Object... args)
                                                  throws ExceptionType extends Throwable
Checks a that a condition is true, failing if it is not.

Parameters:
condition - the condition to be checked
message - the error message
args - the error message arguments
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isNotNull

public final Check<ExceptionType> isNotNull(String varName,
                                            Object var)
                                                       throws ExceptionType extends Throwable
Checks the variable is not null.

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isNull

public final Check<ExceptionType> isNull(String varName,
                                         Object var)
                                                    throws ExceptionType extends Throwable
Checks the variable is null.

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isTrue

public final Check<ExceptionType> isTrue(String varName,
                                         boolean var)
                                                    throws ExceptionType extends Throwable
Checks a that the variable is true, failing with a generated message if it is not.

Parameters:
varName - the name of the variable to be checked
var - the var to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isFalse

public final Check<ExceptionType> isFalse(String varName,
                                          boolean var)
                                                     throws ExceptionType extends Throwable
Checks a that the variable is true, failing with a generated message if it is not.

Parameters:
varName - the name of the variable to be checked
var - the var to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

matches

public final Check<ExceptionType> matches(String varName,
                                          String var,
                                          String regex)
                                                     throws ExceptionType extends Throwable
Checks that the variable is not null and matches a given regular expression.

Parameters:
varName - the name of the variable to be checked
var - the var to be checked
regex - the regular expression the var must match
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable
See Also:
that(boolean, String, Object...)

matches

public final Check<ExceptionType> matches(String varName,
                                          String var,
                                          Pattern pattern)
                                                     throws ExceptionType extends Throwable
Checks that the variable is not null and matches a given pattern

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
pattern - the pattern the variable must match
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable
See Also:
that(boolean, String, Object...)

isEmpty

public final Check<ExceptionType> isEmpty(String varName,
                                          Collection<?> var)
                                                     throws ExceptionType extends Throwable
Checks that the variable is not null and empty

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable
See Also:
that(boolean, String, Object...)

isEmpty

public final Check<ExceptionType> isEmpty(String varName,
                                          Map<?,?> var)
                                                     throws ExceptionType extends Throwable
Checks that the variable is not null and empty

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable
See Also:
that(boolean, String, Object...)

isEmpty

public final Check<ExceptionType> isEmpty(String varName,
                                          Iterable<?> var)
                                                     throws ExceptionType extends Throwable
Checks that the variable is not null and empty

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable
See Also:
that(boolean, String, Object...)

isEmpty

public final Check<ExceptionType> isEmpty(String varName,
                                          CharSequence var)
                                                     throws ExceptionType extends Throwable
Checks that the variable is not null and empty

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable
See Also:
that(boolean, String, Object...)

isEmpty

public final Check<ExceptionType> isEmpty(String varName,
                                          EmptyAware var)
                                                     throws ExceptionType extends Throwable
Checks that the variable is not null and empty

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable
See Also:
that(boolean, String, Object...)

isEmpty

public final <A> Check<ExceptionType> isEmpty(String varName,
                                              A var,
                                              EmptyAwareType<A> type)
                                                     throws ExceptionType extends Throwable
Checks that the variable is not null and empty

Type Parameters:
A -
Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
type - the EmptyAwareType used to determine if var is not empty
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable
See Also:
that(boolean, String, Object...)

isInstanceOf

public final Check<ExceptionType> isInstanceOf(String varName,
                                               Object var,
                                               Class<?> expectedClass)
                                                          throws ExceptionType extends Throwable
Checks that the variable is not null and instance of the given class

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
expectedClass - the class the variable must be instance of
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable
See Also:
that(boolean, String, Object...)

isSize

public final Check<ExceptionType> isSize(String varName,
                                         Collection<?> var,
                                         int size)
                                                    throws ExceptionType extends Throwable
Checks that var is not null and its size is the given expectedSize

Parameters:
varName - the name of the collection variable to be checked
var - the Collection variable to be checked
size - the size the variable must have
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isSize

public final Check<ExceptionType> isSize(String varName,
                                         CharSequence var,
                                         int size)
                                                    throws ExceptionType extends Throwable
Checks that var is not null and its size is the given expectedSize

Parameters:
varName - the name of the char sequence variable to be checked
var - the CharSequence variable to be checked
size - the size the variable must have
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isSize

public final Check<ExceptionType> isSize(String varName,
                                         SizeAware var,
                                         int size)
                                                    throws ExceptionType extends Throwable
Checks that var is not null and its size is the given expectedSize

Parameters:
varName - the name of the size-aware variable to be checked
var - the SizeAware variable to be checked
size - the size the variable must have
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isSize

public final Check<ExceptionType> isSize(String varName,
                                         Map<?,?> var,
                                         int size)
                                                    throws ExceptionType extends Throwable
Checks that var is not null and its size is the given expectedSize

Parameters:
varName - the name of the Map variable to be checked
var - the Map variable to be checked
size - the size the variable must have
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isSize

public final <A> Check<ExceptionType> isSize(String varName,
                                             A var,
                                             int expectedSize,
                                             SizeAwareType<A> type)
                                                    throws ExceptionType extends Throwable
Checks that var is not null and its ize is the given expectedSize

Type Parameters:
A -
Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
expectedSize -
type - the SizeAwareType used to determine if var has the given expectedSize
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable
See Also:
that(boolean, String, Object...)

isMinSize

public final Check<ExceptionType> isMinSize(String varName,
                                            Collection<?> var,
                                            int minSize)
                                                       throws ExceptionType extends Throwable
Checks that var is not null and its size greater than or equals to the the given minSize

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
minSize - the minimum size
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable
See Also:
that(boolean, String, Object...)

isMinSize

public final <A> Check<ExceptionType> isMinSize(String varName,
                                                A var,
                                                int minSize,
                                                SizeAwareType<A> type)
                                                       throws ExceptionType extends Throwable
Checks that var is not null and its size greater than or equals to the the given minSize

Type Parameters:
A -
Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
minSize - the minimum size
type - the SizeAwareType used to determine the var size
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable
See Also:
that(boolean, String, Object...)

isMaxSize

public final Check<ExceptionType> isMaxSize(String varName,
                                            Collection<?> var,
                                            int minSize)
                                                       throws ExceptionType extends Throwable
Checks that var is not null and its size less than or equals to the the given maxSize

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
maxSize - the maximum size
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable
See Also:
that(boolean, String, Object...)

isMaxSize

public final <A> Check<ExceptionType> isMaxSize(String varName,
                                                A var,
                                                int maxSize,
                                                SizeAwareType<A> type)
                                                       throws ExceptionType extends Throwable
Checks that var is not null and its size less than or equals to the the given maxSize

Type Parameters:
A -
Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
maxSize - the maximum size
type - the SizeAwareType used to determine the var size
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable
See Also:
that(boolean, String, Object...)

isNotNegative

public final Check<ExceptionType> isNotNegative(String varName,
                                                long var)
                                                           throws ExceptionType extends Throwable
Checks the variable is >= 0

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isNotNegative

public final Check<ExceptionType> isNotNegative(String varName,
                                                int var)
                                                           throws ExceptionType extends Throwable
Checks the variable is >= 0

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isNotNegative

public final Check<ExceptionType> isNotNegative(String varName,
                                                double var)
                                                           throws ExceptionType extends Throwable
Checks the variable is >= 0

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isNotNegative

public final Check<ExceptionType> isNotNegative(String varName,
                                                float var)
                                                           throws ExceptionType extends Throwable
Checks the variable is >= 0

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isNotNegative

public final Check<ExceptionType> isNotNegative(String varName,
                                                BigDecimal var)
                                                           throws ExceptionType extends Throwable
Checks the variable is >= 0

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isNotNegative

public final Check<ExceptionType> isNotNegative(String varName,
                                                BigInteger var)
                                                           throws ExceptionType extends Throwable
Checks the variable is >= 0

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isNotNegative

public final <A> Check<ExceptionType> isNotNegative(String varName,
                                                    A var,
                                                    NumberType<A> type)
                                                           throws ExceptionType extends Throwable
Checks the var is >= 0

Type Parameters:
A -
Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
type - the NumberType used to determine if var is negative
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isNotZero

public final <A> Check<ExceptionType> isNotZero(String varName,
                                                A var,
                                                NumberType<A> type)
                                                       throws ExceptionType extends Throwable
Checks the var is not null and not equal to 0

Type Parameters:
A -
Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
type - the NumberType used to determine if var is not zero, based on NumberType.isZero(Object)
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isZero

public final <A> Check<ExceptionType> isZero(String varName,
                                             A var,
                                             NumberType<A> type)
                                                    throws ExceptionType extends Throwable
Checks the var is not null and equal to 0

Type Parameters:
A -
Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
type - the NumberType used to determine if var is zero, based on NumberType.isZero(Object)
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isNotEmpty

public final Check<ExceptionType> isNotEmpty(String varName,
                                             EmptyAware var)
                                                        throws ExceptionType extends Throwable
Checks that the EmptyAware var is not null and not empty

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isNotEmpty

public final Check<ExceptionType> isNotEmpty(String varName,
                                             Collection<?> var)
                                                        throws ExceptionType extends Throwable
Checks that the Collection variable is not null and not empty

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isNotEmpty

public final Check<ExceptionType> isNotEmpty(String varName,
                                             CharSequence var)
                                                        throws ExceptionType extends Throwable
Checks that the CharSequence variable is not null and not empty

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isNotEmpty

public final Check<ExceptionType> isNotEmpty(String varName,
                                             Map<?,?> var)
                                                        throws ExceptionType extends Throwable
Checks that the Map variable is not null and not empty

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isNotEmpty

public final Check<ExceptionType> isNotEmpty(String varName,
                                             Iterable<?> var)
                                                        throws ExceptionType extends Throwable
Checks that the Iterable variable is not null and not empty

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isNotEmpty

public final <A> Check<ExceptionType> isNotEmpty(String varName,
                                                 A var,
                                                 EmptyAwareType<A> type)
                                                        throws ExceptionType extends Throwable
Checks that the variable is not null and not empty

Type Parameters:
A -
Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
type - the EmptyAwareType used to determine if var is empty
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable
See Also:
that(boolean, String, Object...)

isPositive

public final Check<ExceptionType> isPositive(String varName,
                                             long var)
                                                        throws ExceptionType extends Throwable
Checks the var is > 0

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isPositive

public final Check<ExceptionType> isPositive(String varName,
                                             int var)
                                                        throws ExceptionType extends Throwable
Checks the var is > 0

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isPositive

public final Check<ExceptionType> isPositive(String varName,
                                             double var)
                                                        throws ExceptionType extends Throwable
Checks the var is > 0

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isPositive

public final Check<ExceptionType> isPositive(String varName,
                                             float var)
                                                        throws ExceptionType extends Throwable
Checks the var is > 0

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isPositive

public final Check<ExceptionType> isPositive(String varName,
                                             BigDecimal var)
                                                        throws ExceptionType extends Throwable
Checks the var is > 0

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isPositive

public final Check<ExceptionType> isPositive(String varName,
                                             BigInteger var)
                                                        throws ExceptionType extends Throwable
Checks the var is not null and > 0

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isPositive

public final <A> Check<ExceptionType> isPositive(String varName,
                                                 A var,
                                                 NumberType<A> type)
                                                        throws ExceptionType extends Throwable
Checks the var is > 0

Type Parameters:
A -
Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
type - the NumberType used to determine if var is positive
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isBetween

public final <T extends Comparable<T>> Check<ExceptionType> isBetween(String varName,
                                                                      T var,
                                                                      T min,
                                                                      T max)
                                                       throws ExceptionType extends Throwable
Checks the var is not null, less than or equal to max and greater than or equal to min

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
min -
max -
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

contains

public final <T> Check<ExceptionType> contains(String varName,
                                               ContainsAware<T> var,
                                               T element)
                                                      throws ExceptionType extends Throwable
Checks that the variable contains the given element

Type Parameters:
T - the contained element type
Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
element - the element that the variable must contain
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isIn

public final <T> Check<ExceptionType> isIn(String varName,
                                           T var,
                                           ContainsAware<T> container)
                                                  throws ExceptionType extends Throwable
Checks the var is not null and contained by the given container

Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
container - the ContainsAware that must contain var
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isGreaterThan

public final <T extends Comparable<T>> Check<ExceptionType> isGreaterThan(String varName,
                                                                          T var,
                                                                          T other)
                                                           throws ExceptionType extends Throwable
Checks that the variable is not null and > than other

Type Parameters:
T - the contained element type
Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
other - the Comparable object of the same type to be compared against var
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isGreaterThanOrEqualTo

public final <T extends Comparable<T>> Check<ExceptionType> isGreaterThanOrEqualTo(String varName,
                                                                                   T var,
                                                                                   T other)
                                                                    throws ExceptionType extends Throwable
Checks that the variable is not null and >= than other

Type Parameters:
T - the contained element type
Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
other - the Comparable object of the same type to be compared against var
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isLessThan

public final <T extends Comparable<T>> Check<ExceptionType> isLessThan(String varName,
                                                                       T var,
                                                                       T other)
                                                        throws ExceptionType extends Throwable
Checks that the variable is not null and < than other

Type Parameters:
T - the contained element type
Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
other - the Comparable object of the same type to be compared against var
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable

isLessThanOrEqualTo

public final <T extends Comparable<T>> Check<ExceptionType> isLessThanOrEqualTo(String varName,
                                                                                T var,
                                                                                T other)
                                                                 throws ExceptionType extends Throwable
Checks that the variable is not null and <= than other

Type Parameters:
T - the contained element type
Parameters:
varName - the name of the variable to be checked
var - the variable to be checked
other - the Comparable object of the same type to be compared against var
Returns:
this, in order to allow method chaining
Throws:
ExceptionType - if the check failed
ExceptionType extends Throwable


Get Staccatocommons at SourceForge.net. Fast, secure and Free Open Source software downloads