Class Postconditions
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckPostcondition(boolean condition, String message) A specialized version ofcheckPostcondition(Object, boolean, Function)that does not mention an input value.static voidcheckPostcondition(boolean condition, Supplier<String> message) A specialized version ofcheckPostcondition(Object, boolean, Function)that does not mention an input value.static <T> TcheckPostcondition(T value, boolean condition, Function<T, String> describer) Evaluate the givenpredicateusingvalueas input.static <T> TcheckPostcondition(T value, ContractConditionType<T> condition) Evaluate the givenpredicateusingvalueas input.static <T> TcheckPostcondition(T value, Predicate<T> predicate, Function<T, String> describer) Evaluate the givenpredicateusingvalueas input.static doublecheckPostconditionD(double value, boolean condition, DoubleFunction<String> describer) Adoublespecialized version ofcheckPostcondition(Object, boolean, Function)static doublecheckPostconditionD(double value, ContractDoubleConditionType condition) Adoublespecialized version ofcheckPostcondition(Object, ContractConditionType).static doublecheckPostconditionD(double value, DoublePredicate predicate, DoubleFunction<String> describer) Adoublespecialized version ofcheckPostcondition(Object, Predicate, Function)static intcheckPostconditionI(int value, boolean condition, IntFunction<String> describer) Anintspecialized version ofcheckPostcondition(Object, boolean, Function).static intcheckPostconditionI(int value, ContractIntConditionType condition) Anintspecialized version ofcheckPostcondition(Object, ContractConditionType).static intcheckPostconditionI(int value, IntPredicate predicate, IntFunction<String> describer) Anintspecialized version ofcheckPostcondition(Object, ContractConditionType).static longcheckPostconditionL(long value, boolean condition, LongFunction<String> describer) Alongspecialized version ofcheckPostcondition(Object, Predicate, Function)static longcheckPostconditionL(long value, ContractLongConditionType condition) Alongspecialized version ofcheckPostcondition(Object, ContractConditionType).static longcheckPostconditionL(long value, LongPredicate predicate, LongFunction<String> describer) Alongspecialized version ofcheckPostcondition(Object, Predicate, Function)static <T> TcheckPostconditions(T value, ContractConditionType<T>... conditions) Evaluate all of the givenconditionsusingvalueas input.static doublecheckPostconditionsD(double value, ContractDoubleConditionType... conditions) Adoublespecialized version ofcheckPostconditions(Object, ContractConditionType[])static intcheckPostconditionsI(int value, ContractIntConditionType... conditions) Anintspecialized version ofcheckPostconditions(Object, ContractConditionType[])static longcheckPostconditionsL(long value, ContractLongConditionType... conditions) Alongspecialized version ofcheckPostconditions(Object, ContractConditionType[])static voidcheckPostconditionV(boolean condition, String format, Object... objects) A version ofcheckPostcondition(boolean, String)that constructs a description message from the given format string and arguments.static <T> TcheckPostconditionV(T value, boolean condition, String format, Object... objects) A version ofcheckPostcondition(boolean, String)that constructs a description message from the given format string and arguments.
-
Method Details
-
checkPostconditions
@SafeVarargs public static <T> T checkPostconditions(T value, ContractConditionType<T>... conditions) throws PostconditionViolationException Evaluate all of the given
conditionsusingvalueas input.All of the conditions are evaluated and the function throws
PostconditionViolationExceptionif any of the conditions are false, or raise an exception that is not of typeError. Exceptions of typeErrorare propagated immediately, without any further contract checking.- Type Parameters:
T- The type of values- Parameters:
value- The valueconditions- The set of conditions- Returns:
- value
- Throws:
PostconditionViolationException- If any of the conditions are false
-
checkPostconditionsI
public static int checkPostconditionsI(int value, ContractIntConditionType... conditions) throws PostconditionViolationException Anintspecialized version ofcheckPostconditions(Object, ContractConditionType[])- Parameters:
value- The valueconditions- The conditions the value must obey- Returns:
- value
- Throws:
PostconditionViolationException- If any of the conditions are false
-
checkPostconditionsL
public static long checkPostconditionsL(long value, ContractLongConditionType... conditions) throws PostconditionViolationException Alongspecialized version ofcheckPostconditions(Object, ContractConditionType[])- Parameters:
value- The valueconditions- The conditions the value must obey- Returns:
- value
- Throws:
PostconditionViolationException- If any of the conditions are false
-
checkPostconditionsD
public static double checkPostconditionsD(double value, ContractDoubleConditionType... conditions) throws PostconditionViolationException Adoublespecialized version ofcheckPostconditions(Object, ContractConditionType[])- Parameters:
value- The valueconditions- The conditions the value must obey- Returns:
- value
- Throws:
PostconditionViolationException- If any of the conditions are false
-
checkPostcondition
public static <T> T checkPostcondition(T value, ContractConditionType<T> condition) throws PostconditionViolationException Evaluate the given
predicateusingvalueas input.The function throws
PostconditionViolationExceptionif the predicate is false.- Type Parameters:
T- The type of values- Parameters:
value- The valuecondition- The predicate- Returns:
- value
- Throws:
PostconditionViolationException- If the predicate is false
-
checkPostcondition
public static <T> T checkPostcondition(T value, Predicate<T> predicate, Function<T, String> describer) Evaluate the given
predicateusingvalueas input.The function throws
PostconditionViolationExceptionif the predicate is false.- Type Parameters:
T- The type of values- Parameters:
value- The valuepredicate- The predicatedescriber- A describer for the predicate- Returns:
- value
- Throws:
PostconditionViolationException- If the predicate is false
-
checkPostcondition
Evaluate the given
predicateusingvalueas input.The function throws
PostconditionViolationExceptionif the predicate is false.- Type Parameters:
T- The type of values- Parameters:
value- The valuecondition- The predicatedescriber- A describer for the predicate- Returns:
- value
- Throws:
PostconditionViolationException- If the predicate is false
-
checkPostcondition
public static void checkPostcondition(boolean condition, String message) throws PostconditionViolationException A specialized version ofcheckPostcondition(Object, boolean, Function)that does not mention an input value.- Parameters:
condition- The predicatemessage- The predicate description- Throws:
PostconditionViolationException- Iffpredicate == false
-
checkPostcondition
public static void checkPostcondition(boolean condition, Supplier<String> message) throws PostconditionViolationException A specialized version ofcheckPostcondition(Object, boolean, Function)that does not mention an input value.- Parameters:
condition- The predicatemessage- The predicate description supplier- Throws:
PostconditionViolationException- Iffpredicate == false
-
checkPostconditionV
public static <T> T checkPostconditionV(T value, boolean condition, String format, Object... objects) A version of
checkPostcondition(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.
- Type Parameters:
T- The precise type of values- Parameters:
value- The valuecondition- The predicateformat- The format stringobjects- The format string arguments- Returns:
value- Since:
- 1.1.0
-
checkPostconditionV
A version of
checkPostcondition(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.
- Parameters:
condition- The predicateformat- The format stringobjects- The format string arguments- Since:
- 1.1.0
-
checkPostconditionI
public static int checkPostconditionI(int value, ContractIntConditionType condition) throws PostconditionViolationException Anintspecialized version ofcheckPostcondition(Object, ContractConditionType).- Parameters:
value- The valuecondition- The predicate- Returns:
- value
- Throws:
PostconditionViolationException- If the predicate is false
-
checkPostconditionI
public static int checkPostconditionI(int value, IntPredicate predicate, IntFunction<String> describer) Anintspecialized version ofcheckPostcondition(Object, ContractConditionType).- Parameters:
value- The valuepredicate- The predicatedescriber- The describer for the predicate- Returns:
- value
- Throws:
PostconditionViolationException- If the predicate is false
-
checkPostconditionI
Anintspecialized version ofcheckPostcondition(Object, boolean, Function).- Parameters:
value- The valuecondition- The predicatedescriber- The describer for the predicate- Returns:
- value
- Throws:
PostconditionViolationException- If the predicate is false
-
checkPostconditionL
public static long checkPostconditionL(long value, ContractLongConditionType condition) throws PostconditionViolationException Alongspecialized version ofcheckPostcondition(Object, ContractConditionType).- Parameters:
value- The valuecondition- The predicate- Returns:
- value
- Throws:
PostconditionViolationException- If the predicate is false
-
checkPostconditionL
public static long checkPostconditionL(long value, LongPredicate predicate, LongFunction<String> describer) Alongspecialized version ofcheckPostcondition(Object, Predicate, Function)- Parameters:
value- The valuepredicate- The predicatedescriber- The describer of the predicate- Returns:
- value
- Throws:
PostconditionViolationException- If the predicate is false
-
checkPostconditionL
public static long checkPostconditionL(long value, boolean condition, LongFunction<String> describer) Alongspecialized version ofcheckPostcondition(Object, Predicate, Function)- Parameters:
condition- The predicatevalue- The valuedescriber- The describer of the predicate- Returns:
- value
- Throws:
PostconditionViolationException- If the predicate is false
-
checkPostconditionD
public static double checkPostconditionD(double value, ContractDoubleConditionType condition) throws PostconditionViolationException Adoublespecialized version ofcheckPostcondition(Object, ContractConditionType).- Parameters:
value- The valuecondition- The predicate- Returns:
- value
- Throws:
PostconditionViolationException- If the predicate is false
-
checkPostconditionD
public static double checkPostconditionD(double value, DoublePredicate predicate, DoubleFunction<String> describer) Adoublespecialized version ofcheckPostcondition(Object, Predicate, Function)- Parameters:
value- The valuepredicate- The predicatedescriber- The describer of the predicate- Returns:
- value
- Throws:
PostconditionViolationException- If the predicate is false
-
checkPostconditionD
public static double checkPostconditionD(double value, boolean condition, DoubleFunction<String> describer) Adoublespecialized version ofcheckPostcondition(Object, boolean, Function)- Parameters:
value- The valuecondition- The predicatedescriber- The describer of the predicate- Returns:
- value
- Throws:
PostconditionViolationException- If the predicate is false
-