public final class Preconditions extends Object
| Modifier and Type | Method | Description |
|---|---|---|
static void |
checkPrecondition(boolean condition,
String message) |
A specialized version of
checkPrecondition(Object, boolean,
Function) that does not mention an input value. |
static void |
checkPrecondition(boolean condition,
Supplier<String> message) |
A specialized version of
checkPrecondition(Object, boolean,
Function) that does not mention an input value. |
static <T> T |
checkPrecondition(T value,
boolean condition,
Function<T,String> describer) |
Evaluate the given
predicate using value as input. |
static <T> T |
checkPrecondition(T value,
ContractConditionType<T> condition) |
Evaluate the given
predicate using value as input. |
static <T> T |
checkPrecondition(T value,
Predicate<T> predicate,
Function<T,String> describer) |
Evaluate the given
predicate using value as input. |
static double |
checkPreconditionD(double value,
boolean condition,
DoubleFunction<String> describer) |
A
double specialized version of checkPrecondition(Object,
boolean, Function) |
static double |
checkPreconditionD(double value,
ContractDoubleConditionType condition) |
A
double specialized version of checkPrecondition(Object,
ContractConditionType). |
static double |
checkPreconditionD(double value,
DoublePredicate predicate,
DoubleFunction<String> describer) |
A
double specialized version of checkPrecondition(Object,
Predicate, Function) |
static int |
checkPreconditionI(int value,
boolean condition,
IntFunction<String> describer) |
An
int specialized version of checkPrecondition(Object,
boolean, Function). |
static int |
checkPreconditionI(int value,
ContractIntConditionType condition) |
An
int specialized version of checkPrecondition(Object,
ContractConditionType). |
static int |
checkPreconditionI(int value,
IntPredicate predicate,
IntFunction<String> describer) |
An
int specialized version of checkPrecondition(Object,
ContractConditionType). |
static long |
checkPreconditionL(long value,
boolean condition,
LongFunction<String> describer) |
A
long specialized version of checkPrecondition(Object,
Predicate, Function) |
static long |
checkPreconditionL(long value,
ContractLongConditionType condition) |
A
long specialized version of checkPrecondition(Object,
ContractConditionType). |
static long |
checkPreconditionL(long value,
LongPredicate predicate,
LongFunction<String> describer) |
A
long specialized version of checkPrecondition(Object,
Predicate, Function) |
static <T> T |
checkPreconditions(T value,
ContractConditionType<T>... conditions) |
Evaluate all of the given
conditions using value as
input. |
static double |
checkPreconditionsD(double value,
ContractDoubleConditionType... conditions) |
A
double specialized version of checkPreconditions(Object,
ContractConditionType[]) |
static int |
checkPreconditionsI(int value,
ContractIntConditionType... conditions) |
An
int specialized version of checkPreconditions(Object,
ContractConditionType[]) |
static long |
checkPreconditionsL(long value,
ContractLongConditionType... conditions) |
A
long specialized version of checkPreconditions(Object,
ContractConditionType[]) |
static void |
checkPreconditionV(boolean condition,
String format,
Object... objects) |
A version of
checkPrecondition(boolean, String) that constructs
a description message from the given format string and arguments. |
static <T> T |
checkPreconditionV(T value,
boolean condition,
String format,
Object... objects) |
A version of
checkPrecondition(boolean, String) that constructs
a description message from the given format string and arguments. |
@SafeVarargs public static <T> T checkPreconditions(T value, ContractConditionType<T>... conditions) throws PreconditionViolationException
Evaluate all of the given conditions using value as
input.
All of the conditions are evaluated and the function throws PreconditionViolationException 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 conditionsPreconditionViolationException - If any of the conditions are falsepublic static int checkPreconditionsI(int value,
ContractIntConditionType... conditions)
throws PreconditionViolationException
int specialized version of checkPreconditions(Object,
ContractConditionType[])value - The valueconditions - The conditions the value must obeyPreconditionViolationException - If any of the conditions are falsepublic static long checkPreconditionsL(long value,
ContractLongConditionType... conditions)
throws PreconditionViolationException
long specialized version of checkPreconditions(Object,
ContractConditionType[])value - The valueconditions - The conditions the value must obeyPreconditionViolationException - If any of the conditions are falsepublic static double checkPreconditionsD(double value,
ContractDoubleConditionType... conditions)
throws PreconditionViolationException
double specialized version of checkPreconditions(Object,
ContractConditionType[])value - The valueconditions - The conditions the value must obeyPreconditionViolationException - If any of the conditions are falsepublic static <T> T checkPrecondition(T value,
ContractConditionType<T> condition)
throws PreconditionViolationException
Evaluate the given predicate using value as input.
The function throws PreconditionViolationException if the
predicate is false.
T - The type of valuesvalue - The valuecondition - The predicatePreconditionViolationException - If the predicate is falsepublic static <T> T checkPrecondition(T value,
Predicate<T> predicate,
Function<T,String> describer)
Evaluate the given predicate using value as input.
The function throws PreconditionViolationException if the
predicate is false.
T - The type of valuesvalue - The valuepredicate - The predicatedescriber - A describer for the predicatePreconditionViolationException - If the predicate is falsepublic static <T> T checkPrecondition(T value,
boolean condition,
Function<T,String> describer)
Evaluate the given predicate using value as input.
The function throws PreconditionViolationException if the
predicate is false.
T - The type of valuesvalue - The valuecondition - The predicatedescriber - A describer for the predicatePreconditionViolationException - If the predicate is falsepublic static void checkPrecondition(boolean condition,
String message)
throws PreconditionViolationException
checkPrecondition(Object, boolean,
Function) that does not mention an input value.condition - The predicatemessage - The predicate descriptionPreconditionViolationException - Iff predicate == falsepublic static void checkPrecondition(boolean condition,
Supplier<String> message)
throws PreconditionViolationException
checkPrecondition(Object, boolean,
Function) that does not mention an input value.condition - The predicatemessage - The predicate description supplierPreconditionViolationException - Iff predicate == falsepublic static <T> T checkPreconditionV(T value,
boolean condition,
String format,
Object... objects)
A version of checkPrecondition(boolean, String) that constructs
a description message from the given format string and arguments.
Note that the use of variadic arguments may entail allocating memory on virtual machines that fail to eliminate the allocations with escape analysis.
T - The precise type of valuesvalue - The valuecondition - The predicateformat - The format stringobjects - The format string argumentsvaluepublic static void checkPreconditionV(boolean condition,
String format,
Object... objects)
A version of checkPrecondition(boolean, String) that constructs
a description message from the given format string and arguments.
Note that the use of variadic arguments may entail allocating memory on virtual machines that fail to eliminate the allocations with escape analysis.
condition - The predicateformat - The format stringobjects - The format string argumentspublic static int checkPreconditionI(int value,
ContractIntConditionType condition)
throws PreconditionViolationException
int specialized version of checkPrecondition(Object,
ContractConditionType).value - The valuecondition - The predicatePreconditionViolationException - If the predicate is falsepublic static int checkPreconditionI(int value,
IntPredicate predicate,
IntFunction<String> describer)
int specialized version of checkPrecondition(Object,
ContractConditionType).value - The valuepredicate - The predicatedescriber - The describer for the predicatePreconditionViolationException - If the predicate is falsepublic static int checkPreconditionI(int value,
boolean condition,
IntFunction<String> describer)
int specialized version of checkPrecondition(Object,
boolean, Function).value - The valuecondition - The predicatedescriber - The describer for the predicatePreconditionViolationException - If the predicate is falsepublic static long checkPreconditionL(long value,
ContractLongConditionType condition)
throws PreconditionViolationException
long specialized version of checkPrecondition(Object,
ContractConditionType).value - The valuecondition - The predicatePreconditionViolationException - If the predicate is falsepublic static long checkPreconditionL(long value,
LongPredicate predicate,
LongFunction<String> describer)
long specialized version of checkPrecondition(Object,
Predicate, Function)value - The valuepredicate - The predicatedescriber - The describer of the predicatePreconditionViolationException - If the predicate is falsepublic static long checkPreconditionL(long value,
boolean condition,
LongFunction<String> describer)
long specialized version of checkPrecondition(Object,
Predicate, Function)condition - The predicatevalue - The valuedescriber - The describer of the predicatePreconditionViolationException - If the predicate is falsepublic static double checkPreconditionD(double value,
ContractDoubleConditionType condition)
throws PreconditionViolationException
double specialized version of checkPrecondition(Object,
ContractConditionType).value - The valuecondition - The predicatePreconditionViolationException - If the predicate is falsepublic static double checkPreconditionD(double value,
DoublePredicate predicate,
DoubleFunction<String> describer)
double specialized version of checkPrecondition(Object,
Predicate, Function)value - The valuepredicate - The predicatedescriber - The describer of the predicatePreconditionViolationException - If the predicate is falsepublic static double checkPreconditionD(double value,
boolean condition,
DoubleFunction<String> describer)
double specialized version of checkPrecondition(Object,
boolean, Function)value - The valuecondition - The predicatedescriber - The describer of the predicatePreconditionViolationException - If the predicate is falseCopyright © 2017 <code@io7m.com> http://io7m.com