public final class Invariants extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
checkInvariant(boolean condition,
String message)
A specialized version of
checkInvariant(Object, boolean, Function)
that does not mention an input value. |
static void |
checkInvariant(boolean condition,
Supplier<String> message)
A specialized version of
checkInvariant(Object, boolean, Function)
that does not mention an input value. |
static <T> T |
checkInvariant(T value,
boolean condition,
Function<T,String> describer)
Evaluate the given
predicate using value as input. |
static <T> T |
checkInvariant(T value,
ContractConditionType<T> condition)
Evaluate the given
predicate using value as input. |
static <T> T |
checkInvariant(T value,
Predicate<T> predicate,
Function<T,String> describer)
Evaluate the given
predicate using value as input. |
static double |
checkInvariantD(double value,
boolean condition,
DoubleFunction<String> describer)
A
double specialized version of checkInvariant(Object,
boolean, Function) |
static double |
checkInvariantD(double value,
ContractDoubleConditionType condition)
A
double specialized version of checkInvariant(Object,
ContractConditionType). |
static double |
checkInvariantD(double value,
DoublePredicate predicate,
DoubleFunction<String> describer)
A
double specialized version of checkInvariant(Object,
Predicate, Function) |
static int |
checkInvariantI(int value,
boolean condition,
IntFunction<String> describer)
An
int specialized version of checkInvariant(Object,
boolean, Function). |
static int |
checkInvariantI(int value,
ContractIntConditionType condition)
An
int specialized version of checkInvariant(Object,
ContractConditionType). |
static int |
checkInvariantI(int value,
IntPredicate predicate,
IntFunction<String> describer)
An
int specialized version of checkInvariant(Object,
ContractConditionType). |
static long |
checkInvariantL(long value,
boolean condition,
LongFunction<String> describer)
A
long specialized version of checkInvariant(Object,
Predicate, Function) |
static long |
checkInvariantL(long value,
ContractLongConditionType condition)
A
long specialized version of checkInvariant(Object,
ContractConditionType). |
static long |
checkInvariantL(long value,
LongPredicate predicate,
LongFunction<String> describer)
A
long specialized version of checkInvariant(Object,
Predicate, Function) |
static <T> T |
checkInvariants(T value,
ContractConditionType<T>... conditions)
Evaluate all of the given
conditions using value as
input. |
static double |
checkInvariantsD(double value,
ContractDoubleConditionType... conditions)
A
double specialized version of checkInvariants(Object,
ContractConditionType[]) |
static int |
checkInvariantsI(int value,
ContractIntConditionType... conditions)
An
int specialized version of checkInvariants(Object,
ContractConditionType[]) |
static long |
checkInvariantsL(long value,
ContractLongConditionType... conditions)
A
long specialized version of checkInvariants(Object,
ContractConditionType[]) |
@SafeVarargs public static <T> T checkInvariants(T value, ContractConditionType<T>... conditions) throws InvariantViolationException
Evaluate all of the given conditions using value as
input.
All of the conditions are evaluated and the function throws InvariantViolationException if any of the conditions are false, or raise
an exception that is not of type Error. Exceptions of type Error are propagated immediately, without any further contract
checking.
T - The type of valuesvalue - The valueconditions - The set of conditionsInvariantViolationException - If any of the conditions are falsepublic static int checkInvariantsI(int value,
ContractIntConditionType... conditions)
throws InvariantViolationException
int specialized version of checkInvariants(Object,
ContractConditionType[])value - The valueconditions - The conditions the value must obeyInvariantViolationException - If any of the conditions are falsepublic static long checkInvariantsL(long value,
ContractLongConditionType... conditions)
throws InvariantViolationException
long specialized version of checkInvariants(Object,
ContractConditionType[])value - The valueconditions - The conditions the value must obeyInvariantViolationException - If any of the conditions are falsepublic static double checkInvariantsD(double value,
ContractDoubleConditionType... conditions)
throws InvariantViolationException
double specialized version of checkInvariants(Object,
ContractConditionType[])value - The valueconditions - The conditions the value must obeyInvariantViolationException - If any of the conditions are falsepublic static <T> T checkInvariant(T value,
ContractConditionType<T> condition)
throws InvariantViolationException
Evaluate the given predicate using value as input.
The function throws InvariantViolationException if the predicate
is false.
T - The type of valuesvalue - The valuecondition - The predicateInvariantViolationException - If the predicate is falsepublic static <T> T checkInvariant(T value,
Predicate<T> predicate,
Function<T,String> describer)
Evaluate the given predicate using value as input.
The function throws InvariantViolationException if the predicate
is false.
T - The type of valuesvalue - The valuepredicate - The predicatedescriber - A describer for the predicateInvariantViolationException - If the predicate is falsepublic static <T> T checkInvariant(T value,
boolean condition,
Function<T,String> describer)
Evaluate the given predicate using value as input.
The function throws InvariantViolationException if the predicate
is false.
T - The type of valuesvalue - The valuecondition - The predicatedescriber - A describer for the predicateInvariantViolationException - If the predicate is falsepublic static void checkInvariant(boolean condition,
String message)
throws InvariantViolationException
checkInvariant(Object, boolean, Function)
that does not mention an input value.condition - The predicatemessage - The predicate descriptionInvariantViolationException - Iff predicate == falsepublic static void checkInvariant(boolean condition,
Supplier<String> message)
throws InvariantViolationException
checkInvariant(Object, boolean, Function)
that does not mention an input value.condition - The predicatemessage - The predicate description supplierInvariantViolationException - Iff predicate == falsepublic static int checkInvariantI(int value,
ContractIntConditionType condition)
throws InvariantViolationException
int specialized version of checkInvariant(Object,
ContractConditionType).value - The valuecondition - The predicateInvariantViolationException - If the predicate is falsepublic static int checkInvariantI(int value,
IntPredicate predicate,
IntFunction<String> describer)
int specialized version of checkInvariant(Object,
ContractConditionType).value - The valuepredicate - The predicatedescriber - The describer for the predicateInvariantViolationException - If the predicate is falsepublic static int checkInvariantI(int value,
boolean condition,
IntFunction<String> describer)
int specialized version of checkInvariant(Object,
boolean, Function).value - The valuecondition - The predicatedescriber - The describer for the predicateInvariantViolationException - If the predicate is falsepublic static long checkInvariantL(long value,
ContractLongConditionType condition)
throws InvariantViolationException
long specialized version of checkInvariant(Object,
ContractConditionType).value - The valuecondition - The predicateInvariantViolationException - If the predicate is falsepublic static long checkInvariantL(long value,
LongPredicate predicate,
LongFunction<String> describer)
long specialized version of checkInvariant(Object,
Predicate, Function)value - The valuepredicate - The predicatedescriber - The describer of the predicateInvariantViolationException - If the predicate is falsepublic static long checkInvariantL(long value,
boolean condition,
LongFunction<String> describer)
long specialized version of checkInvariant(Object,
Predicate, Function)condition - The predicatevalue - The valuedescriber - The describer of the predicateInvariantViolationException - If the predicate is falsepublic static double checkInvariantD(double value,
ContractDoubleConditionType condition)
throws InvariantViolationException
double specialized version of checkInvariant(Object,
ContractConditionType).value - The valuecondition - The predicateInvariantViolationException - If the predicate is falsepublic static double checkInvariantD(double value,
DoublePredicate predicate,
DoubleFunction<String> describer)
double specialized version of checkInvariant(Object,
Predicate, Function)value - The valuepredicate - The predicatedescriber - The describer of the predicateInvariantViolationException - If the predicate is falsepublic static double checkInvariantD(double value,
boolean condition,
DoubleFunction<String> describer)
double specialized version of checkInvariant(Object,
boolean, Function)value - The valuecondition - The predicatedescriber - The describer of the predicateInvariantViolationException - If the predicate is falseCopyright © 2017 <code@io7m.com> http://io7m.com