| 1 | package com.github.dakusui.pcond.core.fluent; | |
| 2 | ||
| 3 | import com.github.dakusui.pcond.fluent.Statement; | |
| 4 | ||
| 5 | import java.util.function.Function; | |
| 6 | import java.util.function.Predicate; | |
| 7 | import java.util.function.Supplier; | |
| 8 | ||
| 9 | import static java.util.Objects.requireNonNull; | |
| 10 | ||
| 11 | public interface Checker< | |
| 12 | V extends Checker<V, T, R>, | |
| 13 | T, | |
| 14 | R> extends | |
| 15 | Matcher<V, T, R>, | |
| 16 | Statement<T> { | |
| 17 | V addCheckPhrase(Function<Checker<?, R, R>, Predicate<R>> clause); | |
| 18 | ||
| 19 | @SuppressWarnings("unchecked") | |
| 20 | default V checkWithPredicate(Predicate<? super R> predicate) { | |
| 21 | requireNonNull(predicate); | |
| 22 |
2
1. checkWithPredicate : replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker::checkWithPredicate → KILLED 2. lambda$checkWithPredicate$0 : replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker::lambda$checkWithPredicate$0 → KILLED |
return addCheckPhrase(w -> (Predicate<R>) predicate); |
| 23 | } | |
| 24 | ||
| 25 | default V predicate(Predicate<? super R> predicate) { | |
| 26 |
1
1. predicate : replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker::predicate → KILLED |
return checkWithPredicate(predicate); |
| 27 | } | |
| 28 | ||
| 29 | default Predicate<T> done() { | |
| 30 |
1
1. done : replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker::done → KILLED |
return statementPredicate(); |
| 31 | } | |
| 32 | ||
| 33 | /** | |
| 34 | * // @formatter:off | |
| 35 | * When you use an assertion method that accepts multiple statements (`Statement`), it requires all the elements in the array (`varargs`) should have the same generic parameter type. | |
| 36 | * However, you sometimes want to check multiple types at once. | |
| 37 | * By calling this method for every statement building method calling chain, you can address the compilation error. | |
| 38 | * | |
| 39 | * [source, java] | |
| 40 | * ``` | |
| 41 | * class Example { | |
| 42 | * public static void main(String... args) { | |
| 43 | * assert all( | |
| 44 | * objectValue(arg[0]).isNotNull().$(), | |
| 45 | * objectValue(new Example()).isNotNull().$(), | |
| 46 | * ... | |
| 47 | * } | |
| 48 | * } | |
| 49 | * ``` | |
| 50 | * | |
| 51 | * // @formatter.off | |
| 52 | * | |
| 53 | * @return A statement for `java.lang.Object` type. | |
| 54 | */ | |
| 55 | @SuppressWarnings("unchecked") | |
| 56 | default Statement<Object> $() { | |
| 57 |
1
1. $ : replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker::$ → KILLED |
return (Statement<Object>) this; |
| 58 | } | |
| 59 | ||
| 60 | abstract class Base< | |
| 61 | V extends Checker<V, T, R>, | |
| 62 | T, | |
| 63 | R> extends | |
| 64 | Matcher.Base< | |
| 65 | V, | |
| 66 | T, | |
| 67 | R | |
| 68 | > implements | |
| 69 | Checker< | |
| 70 | V, | |
| 71 | T, | |
| 72 | R> { | |
| 73 | public Base(Supplier<T> baseValue, Function<T, R> transformFunction) { | |
| 74 | super(baseValue, transformFunction); | |
| 75 | } | |
| 76 | ||
| 77 | @SuppressWarnings("unchecked") | |
| 78 | @Override | |
| 79 | public V addCheckPhrase(Function<Checker<?, R, R>, Predicate<R>> clause) { | |
| 80 |
2
1. addCheckPhrase : replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker$Base::addCheckPhrase → KILLED 2. lambda$addCheckPhrase$0 : replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker$Base::lambda$addCheckPhrase$0 → KILLED |
return this.addPredicate((Matcher<?, R, R> v) -> clause.apply((Checker<?, R, R>) v)); |
| 81 | } | |
| 82 | ||
| 83 | @Override | |
| 84 | public T statementValue() { | |
| 85 |
1
1. statementValue : replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker$Base::statementValue → KILLED |
return this.baseValue(); |
| 86 | } | |
| 87 | ||
| 88 | @Override | |
| 89 | public Predicate<T> statementPredicate() { | |
| 90 |
1
1. statementPredicate : replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker$Base::statementPredicate → KILLED |
return toPredicate(); |
| 91 | } | |
| 92 | } | |
| 93 | } | |
Mutations | ||
| 22 |
1.1 2.2 |
|
| 26 |
1.1 |
|
| 30 |
1.1 |
|
| 57 |
1.1 |
|
| 80 |
1.1 2.2 |
|
| 85 |
1.1 |
|
| 90 |
1.1 |