1 | package com.github.valid8j.pcond.core.fluent; | |
2 | ||
3 | import com.github.valid8j.pcond.fluent.Statement; | |
4 | import com.github.valid8j.pcond.forms.Functions; | |
5 | import com.github.valid8j.pcond.internals.InternalChecks; | |
6 | ||
7 | import java.util.Objects; | |
8 | import java.util.function.BiFunction; | |
9 | import java.util.function.Function; | |
10 | import java.util.function.Predicate; | |
11 | import java.util.function.Supplier; | |
12 | ||
13 | import static java.lang.String.format; | |
14 | import static java.util.Objects.requireNonNull; | |
15 | ||
16 | public interface Transformer< | |
17 | TX extends Transformer<TX, V, T, R>, // SELF | |
18 | V extends Checker<V, T, R>, | |
19 | T, | |
20 | R> extends | |
21 | Matcher<TX, T, R>, | |
22 | Statement<T> { | |
23 | ||
24 | TX addTransformAndCheckClause(Function<Transformer<?, ?, R, R>, Predicate<R>> clause); | |
25 | ||
26 | /** | |
27 | * Returns a checker object for this object. | |
28 | * @return A checker object for this object. | |
29 | */ | |
30 | V then(); | |
31 | ||
32 | @SuppressWarnings("unchecked") | |
33 | default TX satisfies(Function<TX, Statement<T>> clause) { | |
34 | requireNonNull(clause); | |
35 |
2
1. lambda$satisfies$0 : replaced return value with null for com/github/valid8j/pcond/core/fluent/Transformer::lambda$satisfies$0 → KILLED 2. satisfies : replaced return value with null for com/github/valid8j/pcond/core/fluent/Transformer::satisfies → KILLED |
return this.addTransformAndCheckClause(tx -> (Predicate<R>) clause.apply((TX) tx).statementPredicate()); |
36 | } | |
37 | ||
38 | /** | |
39 | * A synonym of {@link Transformer#then()} method. | |
40 | * @return A checker object for this object. | |
41 | */ | |
42 | default V satisfies() { | |
43 |
1
1. satisfies : replaced return value with null for com/github/valid8j/pcond/core/fluent/Transformer::satisfies → KILLED |
return then(); |
44 | } | |
45 | ||
46 | /** | |
47 | * A synonym of {@link Transformer#then()} method. | |
48 | * @return A checker object for this object. | |
49 | */ | |
50 | default V toBe() { | |
51 |
1
1. toBe : replaced return value with null for com/github/valid8j/pcond/core/fluent/Transformer::toBe → KILLED |
return then(); |
52 | } | |
53 | ||
54 | <TY extends Transformer<TY, W, T, RR>, | |
55 | W extends Checker<W, T, RR>, | |
56 | RR> | |
57 | TY transformValueWith(Function<? super R, RR> func, BiFunction<Supplier<T>, Function<T, RR>, TY> transformerFactory); | |
58 | ||
59 | abstract class Base< | |
60 | TX extends Transformer<TX, V, T, R>, // SELF | |
61 | V extends Checker<V, T, R>, | |
62 | T, | |
63 | R> extends | |
64 | Matcher.Base< | |
65 | TX, | |
66 | T, | |
67 | R> implements | |
68 | Transformer< | |
69 | TX, | |
70 | V, | |
71 | T, | |
72 | R> { | |
73 | ||
74 | protected Base(Supplier<T> baseValue, Function<T, R> transformFunction) { | |
75 | super(baseValue, transformFunction); | |
76 | } | |
77 | ||
78 | public V then() { | |
79 |
1
1. lambda$then$0 : replaced return value with "" for com/github/valid8j/pcond/core/fluent/Transformer$Base::lambda$then$0 → NO_COVERAGE |
InternalChecks.requireState(this, Matcher.Base::hasNoChild, v -> format("Predicate is already added. %s", v.childPredicates())); |
80 |
1
1. then : replaced return value with null for com/github/valid8j/pcond/core/fluent/Transformer$Base::then → KILLED |
return toChecker(this.transformFunction()); |
81 | } | |
82 | ||
83 | public < | |
84 | TY extends Transformer<TY, W, T, RR>, | |
85 | W extends Checker<W, T, RR>, | |
86 | RR> | |
87 | TY transformValueWith(Function<? super R, RR> func, BiFunction<Supplier<T>, Function<T, RR>, TY> transformerFactory) { | |
88 | Function<T, R> tf = transformFunction(); | |
89 |
1
1. transformValueWith : negated conditional → KILLED |
@SuppressWarnings("unchecked") Function<T, RR> transformFunction = Objects.equals(tf, Functions.identity()) ? |
90 | (Function<T, RR>) func : | |
91 | tf.andThen(func); | |
92 |
1
1. transformValueWith : replaced return value with null for com/github/valid8j/pcond/core/fluent/Transformer$Base::transformValueWith → KILLED |
return transformerFactory.apply(this::baseValue, transformFunction); |
93 | } | |
94 | ||
95 | @SuppressWarnings("unchecked") | |
96 | @Override | |
97 | public TX addTransformAndCheckClause(Function<Transformer<?, ?, R, R>, Predicate<R>> clause) { | |
98 |
2
1. addTransformAndCheckClause : replaced return value with null for com/github/valid8j/pcond/core/fluent/Transformer$Base::addTransformAndCheckClause → KILLED 2. lambda$addTransformAndCheckClause$1 : replaced return value with null for com/github/valid8j/pcond/core/fluent/Transformer$Base::lambda$addTransformAndCheckClause$1 → KILLED |
return this.addPredicate(tx -> clause.apply((Transformer<?, ?, R, R>) tx)); |
99 | } | |
100 | ||
101 | @Override | |
102 | public T statementValue() { | |
103 |
1
1. statementValue : replaced return value with null for com/github/valid8j/pcond/core/fluent/Transformer$Base::statementValue → KILLED |
return baseValue(); |
104 | } | |
105 | ||
106 | @Override | |
107 | public Predicate<T> statementPredicate() { | |
108 |
1
1. statementPredicate : replaced return value with null for com/github/valid8j/pcond/core/fluent/Transformer$Base::statementPredicate → KILLED |
return toPredicate(); |
109 | } | |
110 | ||
111 | protected abstract V toChecker(Function<T, R> transformFunction); | |
112 | } | |
113 | } | |
Mutations | ||
35 |
1.1 2.2 |
|
43 |
1.1 |
|
51 |
1.1 |
|
79 |
1.1 |
|
80 |
1.1 |
|
89 |
1.1 |
|
92 |
1.1 |
|
98 |
1.1 2.2 |
|
103 |
1.1 |
|
108 |
1.1 |