| 1 | package com.github.valid8j.classic; | |
| 2 | ||
| 3 | import com.github.valid8j.pcond.validator.Validator; | |
| 4 | ||
| 5 | import java.util.function.Predicate; | |
| 6 | ||
| 7 | /** | |
| 8 | * A class that offers entry-points for checking "preconditions" with a normal | |
| 9 | * conditional statement of Java language. | |
| 10 | * That is, `if` or ternary operator, not an `assert` statement. | |
| 11 | * This means, the user of your product is not able to disable the checks you | |
| 12 | * write at runtime, unlike ones written using `assert` statements. | |
| 13 | * | |
| 14 | * The author of library thinks these methods should be used in "public facing" | |
| 15 | * context when the provider of the value to be examined introduced | |
| 16 | * a bug, which makes the condition `false`. | |
| 17 | * | |
| 18 | * For instance, it is an intended use-case, where you call `requireArgument` for | |
| 19 | * a value passed by the caller and the user is expected to make the value satisfy | |
| 20 | * a certain requirement. | |
| 21 | */ | |
| 22 | public enum Requires { | |
| 23 | ; | |
| 24 | ||
| 25 | public static <T> T requireNonNull(T value) { | |
| 26 |
1
1. requireNonNull : replaced return value with null for com/github/valid8j/classic/Requires::requireNonNull → KILLED |
return Validator.instance().requireNonNull(value); |
| 27 | } | |
| 28 | ||
| 29 | public static <T> T requireArgument(T value, Predicate<? super T> cond) { | |
| 30 |
1
1. requireArgument : replaced return value with null for com/github/valid8j/classic/Requires::requireArgument → KILLED |
return Validator.instance().requireArgument(value, cond); |
| 31 | } | |
| 32 | ||
| 33 | public static <T> T requireState(T value, Predicate<? super T> cond) { | |
| 34 |
1
1. requireState : replaced return value with null for com/github/valid8j/classic/Requires::requireState → KILLED |
return Validator.instance().requireState(value, cond); |
| 35 | } | |
| 36 | ||
| 37 | @SuppressWarnings("RedundantThrows") | |
| 38 | public static <T, E extends Throwable> T require( | |
| 39 | T value, | |
| 40 | Predicate<? super T> cond) throws E { | |
| 41 |
1
1. require : replaced return value with null for com/github/valid8j/classic/Requires::require → KILLED |
return Validator.instance().require(value, cond); |
| 42 | } | |
| 43 | ||
| 44 | } | |
Mutations | ||
| 26 |
1.1 |
|
| 30 |
1.1 |
|
| 34 |
1.1 |
|
| 41 |
1.1 |