com.googlecode.jbp.common.requirements
Interface IRequirements

All Known Implementing Classes:
AbstractRequirements, ParamRequirements, PostCondition, PreCondition, Requirements

public interface IRequirements

Defines common methods to check for required application state.

Author:
Yannick LOTH - yannick AT littlej.biz -

Method Summary
<T extends Collection<?>>
T
requireAllInstanceOf(T collParam, Class<?> klassParam, String... messagesParam)
          Checks that all elements of the specified collection are instances of the specified class.
 boolean requireConjunction(boolean... predicatesParam)
          Requires that all predicates are true.
 File requireDirectory(File fileParam, String... messagesParam)
          Checks that the specified File instance refers to a directory.
 String requireDirectory(String filePathParam, String... messagesParam)
          Checks that the specified String instance is a path that refers to a directory.
 boolean requireDisjunction(boolean... predicatesParam)
          Checks that there is a disjunction between the specified predicates.
 boolean requireExclusiveDisjunction(boolean firstPredicateParam, boolean secondPredicateParam)
          Checks that there is a disjunction between the two specified predicates.
 File requireExistingFile(File fileParam, String... messagesParam)
          Checks that the specified File instance refers to an existing file.
 String requireExistingFile(String filePathParam, String... messagesParam)
          Checks that the specified String instance is a path that refers to an existing file.
 boolean requireFalse(boolean boolParam, String... messagesParam)
          Checks that the specified expression returns false.
 Calendar requireFutureInstant(Calendar calendarParam, String... messagesParam)
           
 Date requireFutureInstant(Date dateParam, String... messagesParam)
           
<T> T
requireInstanceOf(T objParam, Class<?> klassParam, String... messagesParam)
          Checks that the specified object is an instance of the specified class.
 Object[] requireNotAllSimultaneouslyNull(Object... objectsParam)
          Checks that at least one reference is not null.
<T extends Collection<?>>
T
requireNotAllSimultaneouslyNull(T coll, String... messagesParam)
          Checks that at least one of the specified objects is not null.
 String requireNotBlank(String strParam, String... messagesParam)
          Checks that a string object is not blank (null or empty or only spaces).
<T extends Collection<?>>
T
requireNotEmpty(T collParam, String... messagesParam)
          Checks that a collection is not empty.
 File requireNotExistingFile(File fileParam, String... messagesParam)
          Checks that the specified File instance refers to a non existing file.
 String requireNotExistingFile(String filePathParam, String... messagesParam)
          Checks that the specified String instance is a path that refers to a non existing file.
<T extends Number>
T
requireNotNegative(T n, String... messagesParam)
          Checks that the specified number is not negative (<0).
<T extends Number>
T
requireNotNegativeNorZero(T n, String... messagesParam)
          Checks that the specified number is not negative (<0) nor zero (0).
<T> T
requireNotNull(T objParam, String... messagesParam)
          Checks that an object is not null.
<T extends Number>
T
requireNotPositive(T n, String... messagesParam)
          Checks that the specified number is not positive (>0).
<T extends Number>
T
requireNotPositiveNorZero(T n, String... messagesParam)
          Checks that the specified number is not positive (>0) nor zero (0).
<T extends Number>
T
requireNotZero(T n, String... messagesParam)
          Checks that the specified number is not zero (0).
<T> T
requireNull(T objParam, String... messagesParam)
          Checks that the specified object is null.
 Calendar requirePastInstant(Calendar dateParam, String... messagesParam)
           
 Date requirePastInstant(Date dateParam, String... messagesParam)
           
 boolean requireTrue(boolean boolParam, String... messagesParam)
          Checks that the specified expression returns true.
 

Method Detail

requireAllInstanceOf

<T extends Collection<?>> T requireAllInstanceOf(T collParam,
                                                 Class<?> klassParam,
                                                 String... messagesParam)
Checks that all elements of the specified collection are instances of the specified class.

Parameters:
collParam - The specified collection.
klassParam - The class which all specified collection's elements should be instances of.
messagesParam - Additional messages with more detail.

requireConjunction

boolean requireConjunction(boolean... predicatesParam)
Requires that all predicates are true. At least one predicate must be specified.

Parameters:
predicatesParam - The specified predicates.
Returns:
true if all predicates are true.

requireDirectory

File requireDirectory(File fileParam,
                      String... messagesParam)
Checks that the specified File instance refers to a directory.

Parameters:
fileParam - The specified file. Must not be null.
messagesParam - Additional messages with more detail.
Returns:
The specified file.

requireDirectory

String requireDirectory(String filePathParam,
                        String... messagesParam)
Checks that the specified String instance is a path that refers to a directory.

Parameters:
filePathParam - The specified file path. Must not be blank.
messagesParam - Additional messages with more detail.
Returns:
The specified file path.

requireDisjunction

boolean requireDisjunction(boolean... predicatesParam)
Checks that there is a disjunction between the specified predicates. In case there is only one predicate, the disjunction is present if the predicate is true. Remember that the values of the predicates are calculated eagerly, before the execution of the method.

Parameters:
predicatesParam - The specified predicates.
Returns:
Returns true if at least one predicate is true.

requireExclusiveDisjunction

boolean requireExclusiveDisjunction(boolean firstPredicateParam,
                                    boolean secondPredicateParam)
Checks that there is a disjunction between the two specified predicates.

Parameters:
firstPredicateParam - The first predicate.
secondPredicateParam - The second predicate.
Returns:
Returns true if exactly one predicate is true.

requireExistingFile

File requireExistingFile(File fileParam,
                         String... messagesParam)
Checks that the specified File instance refers to an existing file.

Parameters:
fileParam - The specified file. Must not be null.
messagesParam - Additional messages with more detail.
Returns:
The specified file.

requireExistingFile

String requireExistingFile(String filePathParam,
                           String... messagesParam)
Checks that the specified String instance is a path that refers to an existing file.

Parameters:
filePathParam - The specified file path. Must not be blank.
messagesParam - Additional messages with more detail.
Returns:
The specified file path.

requireFalse

boolean requireFalse(boolean boolParam,
                     String... messagesParam)
Checks that the specified expression returns false.

Parameters:
boolParam - The expression.
messagesParam - additional messages with more detail.

requireFutureInstant

Calendar requireFutureInstant(Calendar calendarParam,
                              String... messagesParam)

requireFutureInstant

Date requireFutureInstant(Date dateParam,
                          String... messagesParam)

requireInstanceOf

<T> T requireInstanceOf(T objParam,
                        Class<?> klassParam,
                        String... messagesParam)
Checks that the specified object is an instance of the specified class.

Parameters:
objParam - The specified object.
klassParam - The class which the specified object should be an instance of.
messagesParam - additional messages with more detail.

requireNotAllSimultaneouslyNull

Object[] requireNotAllSimultaneouslyNull(Object... objectsParam)
Checks that at least one reference is not null.

Parameters:
objectsParam - The references to objects that may be null.

requireNotAllSimultaneouslyNull

<T extends Collection<?>> T requireNotAllSimultaneouslyNull(T coll,
                                                            String... messagesParam)
Checks that at least one of the specified objects is not null.

Type Parameters:
T - The type of the collection of specified objects.
Parameters:
coll - The collection of specified objects.
messagesParam - additional messages with more detail.
Returns:
The collection of specified objects.

requireNotBlank

String requireNotBlank(String strParam,
                       String... messagesParam)
Checks that a string object is not blank (null or empty or only spaces).

Parameters:
strParam - The string.
messagesParam - additional messages with more detail.

requireNotEmpty

<T extends Collection<?>> T requireNotEmpty(T collParam,
                                            String... messagesParam)
Checks that a collection is not empty. The specified collection must not be null.

Parameters:
collParam - The collection to check for emptyness.
messagesParam - additional messages with more detail.

requireNotExistingFile

File requireNotExistingFile(File fileParam,
                            String... messagesParam)
Checks that the specified File instance refers to a non existing file.

Parameters:
fileParam - The specified file. Must not be null.
messagesParam - Additional messages with more detail.
Returns:
The specified file.

requireNotExistingFile

String requireNotExistingFile(String filePathParam,
                              String... messagesParam)
Checks that the specified String instance is a path that refers to a non existing file.

Parameters:
filePathParam - The specified file path. Must not be blank.
messagesParam - Additional messages with more detail.
Returns:
The specified file path.

requireNotNegative

<T extends Number> T requireNotNegative(T n,
                                        String... messagesParam)
Checks that the specified number is not negative (<0).

Parameters:
n - The specified number.
messagesParam - additional messages with more detail.

requireNotNegativeNorZero

<T extends Number> T requireNotNegativeNorZero(T n,
                                               String... messagesParam)
Checks that the specified number is not negative (<0) nor zero (0).

Parameters:
n - The specified number.
messagesParam - additional messages with more detail.

requireNotNull

<T> T requireNotNull(T objParam,
                     String... messagesParam)
Checks that an object is not null. Example:

 public Foo(Bar bar) {
     this.bar = Objects.requireNotNull(bar);
 }
 

Type Parameters:
T - type of the object.
Parameters:
objParam - The object.
messagesParam - additional messages with more detail.

requireNotPositive

<T extends Number> T requireNotPositive(T n,
                                        String... messagesParam)
Checks that the specified number is not positive (>0).

Parameters:
messagesParam - additional messages with more detail.
n - The specified number.

requireNotPositiveNorZero

<T extends Number> T requireNotPositiveNorZero(T n,
                                               String... messagesParam)
Checks that the specified number is not positive (>0) nor zero (0).

Parameters:
messagesParam - additional messages with more detail.
n - The specified number.

requireNotZero

<T extends Number> T requireNotZero(T n,
                                    String... messagesParam)
Checks that the specified number is not zero (0).

Parameters:
messagesParam - additional messages with more detail.
n - The specified number.

requireNull

<T> T requireNull(T objParam,
                  String... messagesParam)
Checks that the specified object is null.

Type Parameters:
T - The object's type.
Parameters:
objParam - The specified object.
messagesParam - additional messages with more detail.
Returns:
The specified object.

requirePastInstant

Calendar requirePastInstant(Calendar dateParam,
                            String... messagesParam)

requirePastInstant

Date requirePastInstant(Date dateParam,
                        String... messagesParam)

requireTrue

boolean requireTrue(boolean boolParam,
                    String... messagesParam)
Checks that the specified expression returns true.

Parameters:
messagesParam - additional messages with more detail.
boolParam - The expression.


Copyright © 2011. All Rights Reserved.