|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.googlecode.jbp.common.requirements.AbstractRequirements
public abstract class AbstractRequirements
Abstract implementation of IRequirements which provides the
checks but not the action that has to be taken if a condition is not met. All
methods that accept a vararg String... parameter will
concatenate all elements of this array to each other and to the default
message associated to the check and then transmit this String to
the conditionNotMet methods. Thus, the user of these methods may
specify additional information.
| Constructor Summary | |
|---|---|
AbstractRequirements()
|
|
| Method Summary | ||
|---|---|---|
protected abstract void |
onConditionNotMet(String messageParam)
Called if a condition is not met. |
|
|
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)
|
|
|
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. |
|
|
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). |
|
|
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. |
|
|
requireNotNegative(T n,
String... messagesParam)
Checks that the specified number is not negative (<0). |
|
|
requireNotNegativeNorZero(T n,
String... messagesParam)
Checks that the specified number is not negative (<0) nor zero (0). |
|
|
requireNotNull(T objParam,
String... messagesParam)
Checks that an object is not null. |
|
|
requireNotPositive(T n,
String... messagesParam)
Checks that the specified number is not positive (>0). |
|
|
requireNotPositiveNorZero(T n,
String... messagesParam)
Checks that the specified number is not positive (>0) nor zero (0). |
|
|
requireNotZero(T n,
String... messagesParam)
Checks that the specified number is not zero (0). |
|
|
requireNull(T objParam,
String... messagesParam)
Checks that the specified object is null. |
|
Calendar |
requirePastInstant(Calendar calendarParam,
String... messagesParam)
|
|
Date |
requirePastInstant(Date dateParam,
String... messagesParam)
|
|
boolean |
requireTrue(boolean boolParam,
String... messagesParam)
Checks that the specified expression returns true. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractRequirements()
| Method Detail |
|---|
protected abstract void onConditionNotMet(String messageParam)
RequirementException.
messageParam - The associated message.
public final <T extends Collection<?>> T requireAllInstanceOf(T collParam,
Class<?> klassParam,
String... messagesParam)
IRequirements
requireAllInstanceOf in interface IRequirementscollParam - The specified collection.klassParam - The class which all specified collection's elements should be
instances of.messagesParam - Additional messages with more detail.public final boolean requireConjunction(boolean... predicatesParam)
IRequirementstrue. At least one
predicate must be specified.
requireConjunction in interface IRequirementspredicatesParam - The specified predicates.
true if all predicates are true.
public final File requireDirectory(File fileParam,
String... messagesParam)
IRequirementsFile instance refers to a
directory.
requireDirectory in interface IRequirementsfileParam - The specified file. Must not be null.messagesParam - Additional messages with more detail.
public final String requireDirectory(String filePathParam,
String... messagesParam)
IRequirementsString instance is a path that
refers to a directory.
requireDirectory in interface IRequirementsfilePathParam - The specified file path. Must not be blank.messagesParam - Additional messages with more detail.
public final boolean requireDisjunction(boolean... predicatesParam)
IRequirementstrue. Remember that the values of the
predicates are calculated eagerly, before the execution of the method.
requireDisjunction in interface IRequirementspredicatesParam - The specified predicates.
true if at least one predicate is
true.
public final boolean requireExclusiveDisjunction(boolean firstPredicateParam,
boolean secondPredicateParam)
IRequirements
requireExclusiveDisjunction in interface IRequirementsfirstPredicateParam - The first predicate.secondPredicateParam - The second predicate.
true if exactly one predicate is
true.
public final File requireExistingFile(File fileParam,
String... messagesParam)
IRequirementsFile instance refers to an
existing file.
requireExistingFile in interface IRequirementsfileParam - The specified file. Must not be null.messagesParam - Additional messages with more detail.
public final String requireExistingFile(String filePathParam,
String... messagesParam)
IRequirementsString instance is a path that
refers to an existing file.
requireExistingFile in interface IRequirementsfilePathParam - The specified file path. Must not be blank.messagesParam - Additional messages with more detail.
public final boolean requireFalse(boolean boolParam,
String... messagesParam)
IRequirements
requireFalse in interface IRequirementsboolParam - The expression.messagesParam - additional messages with more detail.
public final Calendar requireFutureInstant(Calendar calendarParam,
String... messagesParam)
requireFutureInstant in interface IRequirements
public final Date requireFutureInstant(Date dateParam,
String... messagesParam)
requireFutureInstant in interface IRequirements
public final <T> T requireInstanceOf(T objParam,
Class<?> klassParam,
String... messagesParam)
IRequirements
requireInstanceOf in interface IRequirementsobjParam - The specified object.klassParam - The class which the specified object should be an instance of.messagesParam - additional messages with more detail.public final Object[] requireNotAllSimultaneouslyNull(Object... objectsParam)
IRequirements
requireNotAllSimultaneouslyNull in interface IRequirementsobjectsParam - The references to objects that may be null.
public final <T extends Collection<?>> T requireNotAllSimultaneouslyNull(T coll,
String... messagesParam)
IRequirementsnull.
requireNotAllSimultaneouslyNull in interface IRequirementsT - The type of the collection of specified objects.coll - The collection of specified objects.messagesParam - additional messages with more detail.
public final String requireNotBlank(String strParam,
String... messagesParam)
IRequirements
requireNotBlank in interface IRequirementsstrParam - The string.messagesParam - additional messages with more detail.
public final <T extends Collection<?>> T requireNotEmpty(T collParam,
String... messagesParam)
IRequirements
requireNotEmpty in interface IRequirementscollParam - The collection to check for emptyness.messagesParam - additional messages with more detail.
public final File requireNotExistingFile(File fileParam,
String... messagesParam)
IRequirementsFile instance refers to a non
existing file.
requireNotExistingFile in interface IRequirementsfileParam - The specified file. Must not be null.messagesParam - Additional messages with more detail.
public final String requireNotExistingFile(String filePathParam,
String... messagesParam)
IRequirementsString instance is a path that
refers to a non existing file.
requireNotExistingFile in interface IRequirementsfilePathParam - The specified file path. Must not be blank.messagesParam - Additional messages with more detail.
public final <T extends Number> T requireNotNegative(T n,
String... messagesParam)
IRequirements
requireNotNegative in interface IRequirementsn - The specified number.messagesParam - additional messages with more detail.
public final <T extends Number> T requireNotNegativeNorZero(T n,
String... messagesParam)
IRequirements
requireNotNegativeNorZero in interface IRequirementsn - The specified number.messagesParam - additional messages with more detail.
public final <T> T requireNotNull(T objParam,
String... messagesParam)
IRequirements
public Foo(Bar bar) {
this.bar = Objects.requireNotNull(bar);
}
requireNotNull in interface IRequirementsT - type of the object.objParam - The object.messagesParam - additional messages with more detail.
public final <T extends Number> T requireNotPositive(T n,
String... messagesParam)
IRequirements
requireNotPositive in interface IRequirementsn - The specified number.messagesParam - additional messages with more detail.
public final <T extends Number> T requireNotPositiveNorZero(T n,
String... messagesParam)
IRequirements
requireNotPositiveNorZero in interface IRequirementsn - The specified number.messagesParam - additional messages with more detail.
public final <T extends Number> T requireNotZero(T n,
String... messagesParam)
IRequirements
requireNotZero in interface IRequirementsn - The specified number.messagesParam - additional messages with more detail.
public final <T> T requireNull(T objParam,
String... messagesParam)
IRequirementsnull.
requireNull in interface IRequirementsT - The object's type.objParam - The specified object.messagesParam - additional messages with more detail.
public final Calendar requirePastInstant(Calendar calendarParam,
String... messagesParam)
requirePastInstant in interface IRequirements
public final Date requirePastInstant(Date dateParam,
String... messagesParam)
requirePastInstant in interface IRequirements
public final boolean requireTrue(boolean boolParam,
String... messagesParam)
IRequirements
requireTrue in interface IRequirementsboolParam - The expression.messagesParam - additional messages with more detail.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||