| 1 | package com.github.valid8j.fluent.internals; | |
| 2 | ||
| 3 | import com.github.valid8j.classic.Assertions; | |
| 4 | import com.github.valid8j.classic.Ensures; | |
| 5 | import com.github.valid8j.classic.Requires; | |
| 6 | import com.github.valid8j.pcond.core.fluent.builtins.ObjectTransformer; | |
| 7 | import com.github.valid8j.pcond.fluent.Statement; | |
| 8 | ||
| 9 | import java.util.Arrays; | |
| 10 | import java.util.List; | |
| 11 | import java.util.function.Predicate; | |
| 12 | ||
| 13 | import static java.util.stream.Collectors.toList; | |
| 14 | ||
| 15 | /** | |
| 16 | * A facade class to provide fluent versions of `valid8j` entry points. | |
| 17 | * You can pass `Statement` objects created by static methods in `Statement` interface such as | |
| 18 | * `objectValue`, `stringValue`, `intValue`, etc. | |
| 19 | * | |
| 20 | * @see Statement | |
| 21 | */ | |
| 22 | public enum ValidationFluents { | |
| 23 | ; | |
| 24 | ||
| 25 | /** | |
| 26 | * Fluent version of {@link Requires#requireArgument(Object, Predicate)}. | |
| 27 | * | |
| 28 | * @param statement A statement to be verified | |
| 29 | */ | |
| 30 | public static <T> T requireArgument(Statement<T> statement) { | |
| 31 |
1
1. requireArgument : replaced return value with null for com/github/valid8j/fluent/internals/ValidationFluents::requireArgument → KILLED |
return Requires.requireArgument(statement.statementValue(), statement.statementPredicate()); |
| 32 | } | |
| 33 | ||
| 34 | /** | |
| 35 | * Fluent version of {@link Requires#requireArgument(Object, Predicate)}. | |
| 36 | * Use this method when you need to verify multiple values. | |
| 37 | * | |
| 38 | * @param statements Statements to be verified | |
| 39 | */ | |
| 40 | public static void requireArguments(Statement<?>... statements) { | |
| 41 | List<?> values = Arrays.stream(statements).map(Statement::statementValue).collect(toList()); | |
| 42 | Requires.requireArgument(values, Statement.createPredicateForAllOf(statements)); | |
| 43 | } | |
| 44 | ||
| 45 | public static <T> T requireStatement(Statement<T> statement) { | |
| 46 |
1
1. requireStatement : replaced return value with null for com/github/valid8j/fluent/internals/ValidationFluents::requireStatement → KILLED |
return Requires.require(statement.statementValue(), statement.statementPredicate()); |
| 47 | } | |
| 48 | ||
| 49 | /** | |
| 50 | * Fluent version of {@link Requires#require(Object, Predicate)}. | |
| 51 | * Use this method when you need to verify multiple values. | |
| 52 | * | |
| 53 | * @param statements Statements to be verified | |
| 54 | */ | |
| 55 | public static void requireAll(Statement<?>... statements) { | |
| 56 | List<?> values = Arrays.stream(statements).map(Statement::statementValue).collect(toList()); | |
| 57 | Requires.require(values, Statement.createPredicateForAllOf(statements)); | |
| 58 | } | |
| 59 | ||
| 60 | public static <T> T requireState(Statement<T> statement) { | |
| 61 |
1
1. requireState : replaced return value with null for com/github/valid8j/fluent/internals/ValidationFluents::requireState → KILLED |
return Requires.requireState(statement.statementValue(), statement.statementPredicate()); |
| 62 | } | |
| 63 | ||
| 64 | /** | |
| 65 | * Fluent version of {@link Requires#requireState(Object, Predicate)}. | |
| 66 | * Use this method when you need to verify multiple values. | |
| 67 | * | |
| 68 | * @param statements Statements to be verified | |
| 69 | */ | |
| 70 | public static void requireStates(Statement<?>... statements) { | |
| 71 | List<?> values = Arrays.stream(statements).map(Statement::statementValue).collect(toList()); | |
| 72 | Requires.requireState(values, Statement.createPredicateForAllOf(statements)); | |
| 73 | } | |
| 74 | ||
| 75 | public static <T> T ensureStatement(Statement<T> statement) { | |
| 76 |
1
1. ensureStatement : replaced return value with null for com/github/valid8j/fluent/internals/ValidationFluents::ensureStatement → KILLED |
return Ensures.ensure(statement.statementValue(), statement.statementPredicate()); |
| 77 | } | |
| 78 | ||
| 79 | /** | |
| 80 | * Fluent version of {@link Ensures#ensure(Object, Predicate)}. | |
| 81 | * Use this method when you need to verify multiple values. | |
| 82 | * | |
| 83 | * @param statements Statements to be verified | |
| 84 | */ | |
| 85 | public static void ensureAll(Statement<?>... statements) { | |
| 86 | List<?> values = Arrays.stream(statements).map(Statement::statementValue).collect(toList()); | |
| 87 | Ensures.ensure(values, Statement.createPredicateForAllOf(statements)); | |
| 88 | } | |
| 89 | ||
| 90 | /** | |
| 91 | * Fluent version of {@link Ensures#ensureState(Object, Predicate)}. | |
| 92 | * Use this method when you need to verify multiple values. | |
| 93 | * | |
| 94 | * @param statement A statement to be verified | |
| 95 | */ | |
| 96 | public static <T> T ensureState(Statement<T> statement) { | |
| 97 |
1
1. ensureState : replaced return value with null for com/github/valid8j/fluent/internals/ValidationFluents::ensureState → KILLED |
return Ensures.ensureState(statement.statementValue(), statement.statementPredicate()); |
| 98 | } | |
| 99 | ||
| 100 | /** | |
| 101 | * Fluent version of {@link Ensures#ensureState(Object, Predicate)}. | |
| 102 | * Use this method when you need to verify multiple values. | |
| 103 | * | |
| 104 | * @param statements Statements to be verified | |
| 105 | */ | |
| 106 | public static void ensureStates(Statement<?>... statements) { | |
| 107 | List<?> values = Arrays.stream(statements).map(Statement::statementValue).collect(toList()); | |
| 108 | Ensures.ensureState(values, Statement.createPredicateForAllOf(statements)); | |
| 109 | } | |
| 110 | ||
| 111 | /** | |
| 112 | * Fluent version of {@link Assertions#that(Object, Predicate)}. | |
| 113 | * Use this method when you need to verify multiple values. | |
| 114 | * | |
| 115 | * @param statement A statement to be verified | |
| 116 | */ | |
| 117 | public static <T> boolean that(Statement<T> statement) { | |
| 118 |
2
1. that : replaced boolean return with true for com/github/valid8j/fluent/internals/ValidationFluents::that → SURVIVED 2. that : replaced boolean return with false for com/github/valid8j/fluent/internals/ValidationFluents::that → KILLED |
return Assertions.that(statement.statementValue(), statement.statementPredicate()); |
| 119 | } | |
| 120 | ||
| 121 | /** | |
| 122 | * Fluent version of {@link Assertions#that(Object, Predicate)}. | |
| 123 | * Use this method when you need to verify multiple values. | |
| 124 | * | |
| 125 | * @param statements Statements to be verified | |
| 126 | */ | |
| 127 | public static boolean all(Statement<?>... statements) { | |
| 128 | List<?> values = Arrays.stream(statements).map(Statement::statementValue).collect(toList()); | |
| 129 |
2
1. all : replaced boolean return with true for com/github/valid8j/fluent/internals/ValidationFluents::all → SURVIVED 2. all : replaced boolean return with false for com/github/valid8j/fluent/internals/ValidationFluents::all → KILLED |
return Assertions.that(values, Statement.createPredicateForAllOf(statements)); |
| 130 | } | |
| 131 | ||
| 132 | /** | |
| 133 | * Fluent version of {@link Assertions#precondition(Object, Predicate)}. | |
| 134 | * Use this method when you need to verify multiple values. | |
| 135 | * | |
| 136 | * @param statement A statement to be verified | |
| 137 | */ | |
| 138 | public static <T> boolean precondition(Statement<T> statement) { | |
| 139 |
2
1. precondition : replaced boolean return with true for com/github/valid8j/fluent/internals/ValidationFluents::precondition → SURVIVED 2. precondition : replaced boolean return with false for com/github/valid8j/fluent/internals/ValidationFluents::precondition → KILLED |
return Assertions.precondition(statement.statementValue(), statement.statementPredicate()); |
| 140 | } | |
| 141 | ||
| 142 | /** | |
| 143 | * Fluent version of {@link Assertions#precondition(Object, Predicate)}. | |
| 144 | * Use this method when you need to verify multiple values. | |
| 145 | * | |
| 146 | * @param statements Statements to be verified | |
| 147 | */ | |
| 148 | public static boolean preconditions(Statement<?>... statements) { | |
| 149 | List<?> values = Arrays.stream(statements).map(Statement::statementValue).collect(toList()); | |
| 150 |
2
1. preconditions : replaced boolean return with true for com/github/valid8j/fluent/internals/ValidationFluents::preconditions → SURVIVED 2. preconditions : replaced boolean return with false for com/github/valid8j/fluent/internals/ValidationFluents::preconditions → KILLED |
return Assertions.precondition(values, Statement.createPredicateForAllOf(statements)); |
| 151 | } | |
| 152 | ||
| 153 | /** | |
| 154 | * Fluent version of {@link Assertions#postcondition(Object, Predicate)}. | |
| 155 | * | |
| 156 | * @param statement A statement to be verified | |
| 157 | */ | |
| 158 | public static <T> boolean postcondition(Statement<T> statement) { | |
| 159 |
2
1. postcondition : replaced boolean return with true for com/github/valid8j/fluent/internals/ValidationFluents::postcondition → SURVIVED 2. postcondition : replaced boolean return with false for com/github/valid8j/fluent/internals/ValidationFluents::postcondition → KILLED |
return Assertions.postcondition(statement.statementValue(), statement.statementPredicate()); |
| 160 | } | |
| 161 | ||
| 162 | /** | |
| 163 | * Fluent version of {@link Assertions#postcondition(Object, Predicate)}. | |
| 164 | * Use this method when you need to verify multiple values. | |
| 165 | * | |
| 166 | * @param statements Statements to be verified | |
| 167 | */ | |
| 168 | public static boolean postconditions(Statement<?>... statements) { | |
| 169 | List<?> values = Arrays.stream(statements).map(Statement::statementValue).collect(toList()); | |
| 170 |
2
1. postconditions : replaced boolean return with true for com/github/valid8j/fluent/internals/ValidationFluents::postconditions → SURVIVED 2. postconditions : replaced boolean return with false for com/github/valid8j/fluent/internals/ValidationFluents::postconditions → KILLED |
return Assertions.postcondition(values, Statement.createPredicateForAllOf(statements)); |
| 171 | } | |
| 172 | ||
| 173 | public static <E> ObjectTransformer<E, E> value(E object) { | |
| 174 |
1
1. value : replaced return value with null for com/github/valid8j/fluent/internals/ValidationFluents::value → KILLED |
return Statement.objectValue(object); |
| 175 | } | |
| 176 | } | |
Mutations | ||
| 31 |
1.1 |
|
| 46 |
1.1 |
|
| 61 |
1.1 |
|
| 76 |
1.1 |
|
| 97 |
1.1 |
|
| 118 |
1.1 2.2 |
|
| 129 |
1.1 2.2 |
|
| 139 |
1.1 2.2 |
|
| 150 |
1.1 2.2 |
|
| 159 |
1.1 2.2 |
|
| 170 |
1.1 2.2 |
|
| 174 |
1.1 |