1 | package com.github.valid8j.pcond.fluent; | |
2 | ||
3 | import com.github.valid8j.pcond.core.fluent.builtins.*; | |
4 | import com.github.valid8j.pcond.forms.Functions; | |
5 | ||
6 | import java.util.Arrays; | |
7 | import java.util.List; | |
8 | import java.util.NoSuchElementException; | |
9 | import java.util.concurrent.atomic.AtomicInteger; | |
10 | import java.util.function.Predicate; | |
11 | import java.util.stream.Stream; | |
12 | ||
13 | import static com.github.valid8j.pcond.forms.Predicates.allOf; | |
14 | import static com.github.valid8j.pcond.forms.Predicates.transform; | |
15 | import static com.github.valid8j.pcond.internals.InternalUtils.makeSquashable; | |
16 | ||
17 | /** | |
18 | * An interface to model a "statement", which . | |
19 | * | |
20 | * @param <T> A type of value held by an instance of this interface. | |
21 | */ | |
22 | @FunctionalInterface | |
23 | public interface Statement<T> { | |
24 | /** | |
25 | * Creates a predicate which conjunctions all the given statements. | |
26 | * | |
27 | * @param statements statements to be conjunctioned. | |
28 | * @return A created predicate. | |
29 | */ | |
30 | static Predicate<? super List<?>> createPredicateForAllOf(Statement<?>[] statements) { | |
31 | AtomicInteger i = new AtomicInteger(0); | |
32 | @SuppressWarnings("unchecked") Predicate<? super List<?>>[] predicates = Arrays.stream(statements) | |
33 |
1
1. lambda$createPredicateForAllOf$0 : replaced return value with null for com/github/valid8j/pcond/fluent/Statement::lambda$createPredicateForAllOf$0 → KILLED |
.map(e -> makeSquashable(transform(Functions.elementAt(i.getAndIncrement())).check("WHEN", (Predicate<? super Object>) e.statementPredicate()))) |
34 |
1
1. lambda$createPredicateForAllOf$1 : replaced return value with null for com/github/valid8j/pcond/fluent/Statement::lambda$createPredicateForAllOf$1 → KILLED |
.toArray(Predicate[]::new); |
35 |
1
1. createPredicateForAllOf : replaced return value with null for com/github/valid8j/pcond/fluent/Statement::createPredicateForAllOf → KILLED |
return makeSquashable(allOf(predicates)); |
36 | } | |
37 | ||
38 | /** | |
39 | * Returns a value to be evaluated, "target value", by an instance of this interface. | |
40 | * | |
41 | * @return the value to be evaluated. | |
42 | */ | |
43 | default T statementValue() { | |
44 | throw new NoSuchElementException(); | |
45 | } | |
46 | ||
47 | /** | |
48 | * Returns a predicate to evaluate the target value. | |
49 | * | |
50 | * @return A predicate to evaluate the target value. | |
51 | */ | |
52 | Predicate<T> statementPredicate(); | |
53 | ||
54 | /** | |
55 | * Returns a transformer for a `String` value. | |
56 | * | |
57 | * @param value A value for which a transformer is created. | |
58 | * @return A transformer for a {@code value}. | |
59 | * @see StringTransformer | |
60 | */ | |
61 | static StringTransformer<String> | |
62 | stringValue(String value) { | |
63 |
2
1. lambda$stringValue$2 : replaced return value with "" for com/github/valid8j/pcond/fluent/Statement::lambda$stringValue$2 → KILLED 2. stringValue : replaced return value with null for com/github/valid8j/pcond/fluent/Statement::stringValue → KILLED |
return StringTransformer.create(() -> value); |
64 | } | |
65 | ||
66 | /** | |
67 | * Returns a transformer for a `double` value. | |
68 | * | |
69 | * @param value A value for which a transformer is created. | |
70 | * @return A transformer for a {@code value}. | |
71 | * @see DoubleTransformer | |
72 | */ | |
73 | static DoubleTransformer<Double> | |
74 | doubleValue(Double value) { | |
75 |
2
1. doubleValue : replaced return value with null for com/github/valid8j/pcond/fluent/Statement::doubleValue → KILLED 2. lambda$doubleValue$3 : replaced Double return value with 0 for com/github/valid8j/pcond/fluent/Statement::lambda$doubleValue$3 → KILLED |
return DoubleTransformer.create(() -> value); |
76 | } | |
77 | ||
78 | /** | |
79 | * Returns a transformer for a `float` value. | |
80 | * | |
81 | * @param value A value for which a transformer is created. | |
82 | * @return A transformer for a {@code value}. | |
83 | * @see FloatTransformer | |
84 | */ | |
85 | static FloatTransformer<Float> | |
86 | floatValue(Float value) { | |
87 |
2
1. floatValue : replaced return value with null for com/github/valid8j/pcond/fluent/Statement::floatValue → KILLED 2. lambda$floatValue$4 : replaced Float return value with 0 for com/github/valid8j/pcond/fluent/Statement::lambda$floatValue$4 → KILLED |
return FloatTransformer.create(() -> value); |
88 | } | |
89 | ||
90 | /** | |
91 | * Returns a transformer for a `long` value. | |
92 | * | |
93 | * @param value A value for which a transformer is created. | |
94 | * @return A transformer for a {@code value}. | |
95 | * @see LongTransformer | |
96 | */ | |
97 | static LongTransformer<Long> | |
98 | longValue(Long value) { | |
99 |
2
1. lambda$longValue$5 : replaced Long return value with 0L for com/github/valid8j/pcond/fluent/Statement::lambda$longValue$5 → KILLED 2. longValue : replaced return value with null for com/github/valid8j/pcond/fluent/Statement::longValue → KILLED |
return LongTransformer.create(() -> value); |
100 | } | |
101 | ||
102 | /** | |
103 | * Returns a transformer for a `int` value. | |
104 | * | |
105 | * @param value A value for which a transformer is created. | |
106 | * @return A transformer for a {@code value}. | |
107 | * @see IntegerTransformer | |
108 | */ | |
109 | static IntegerTransformer<Integer> | |
110 | integerValue(Integer value) { | |
111 |
2
1. integerValue : replaced return value with null for com/github/valid8j/pcond/fluent/Statement::integerValue → KILLED 2. lambda$integerValue$6 : replaced Integer return value with 0 for com/github/valid8j/pcond/fluent/Statement::lambda$integerValue$6 → KILLED |
return IntegerTransformer.create(() -> value); |
112 | } | |
113 | ||
114 | /** | |
115 | * Returns a transformer for a `short` value. | |
116 | * | |
117 | * @param value A value for which a transformer is created. | |
118 | * @return A transformer for a {@code value}. | |
119 | * @see ShortTransformer | |
120 | */ | |
121 | static ShortTransformer<Short> | |
122 | shortValue(Short value) { | |
123 |
2
1. lambda$shortValue$7 : replaced Short return value with 0 for com/github/valid8j/pcond/fluent/Statement::lambda$shortValue$7 → KILLED 2. shortValue : replaced return value with null for com/github/valid8j/pcond/fluent/Statement::shortValue → KILLED |
return ShortTransformer.create(() -> value); |
124 | } | |
125 | ||
126 | /** | |
127 | * Returns a transformer for a `boolean` value. | |
128 | * | |
129 | * @param value A value for which a transformer is created. | |
130 | * @return A transformer for a {@code value}. | |
131 | * @see BooleanTransformer | |
132 | */ | |
133 | static BooleanTransformer<Boolean> | |
134 | booleanValue(Boolean value) { | |
135 |
3
1. booleanValue : replaced return value with null for com/github/valid8j/pcond/fluent/Statement::booleanValue → KILLED 2. lambda$booleanValue$8 : replaced Boolean return with False for com/github/valid8j/pcond/fluent/Statement::lambda$booleanValue$8 → KILLED 3. lambda$booleanValue$8 : replaced Boolean return with True for com/github/valid8j/pcond/fluent/Statement::lambda$booleanValue$8 → KILLED |
return BooleanTransformer.create(() -> value); |
136 | } | |
137 | ||
138 | /** | |
139 | * Returns a transformer for a general `Object` value. | |
140 | * | |
141 | * @param value A value for which a transformer is created. | |
142 | * @return A transformer for a {@code value}. | |
143 | * @see ObjectTransformer | |
144 | */ | |
145 | static <E> | |
146 | ObjectTransformer<E, E> | |
147 | objectValue(E value) { | |
148 |
2
1. lambda$objectValue$9 : replaced return value with null for com/github/valid8j/pcond/fluent/Statement::lambda$objectValue$9 → KILLED 2. objectValue : replaced return value with null for com/github/valid8j/pcond/fluent/Statement::objectValue → KILLED |
return ObjectTransformer.create(() -> value); |
149 | } | |
150 | ||
151 | /** | |
152 | * Returns a transformer for a `List` value. | |
153 | * | |
154 | * @param value A value for which a transformer is created. | |
155 | * @return A transformer for a {@code value}. | |
156 | * @see ListTransformer | |
157 | */ | |
158 | ||
159 | static <E> | |
160 | ListTransformer<List<E>, E> | |
161 | listValue(List<E> value) { | |
162 |
2
1. lambda$listValue$10 : replaced return value with Collections.emptyList for com/github/valid8j/pcond/fluent/Statement::lambda$listValue$10 → KILLED 2. listValue : replaced return value with null for com/github/valid8j/pcond/fluent/Statement::listValue → KILLED |
return ListTransformer.create(() -> value); |
163 | } | |
164 | ||
165 | /** | |
166 | * Returns a transformer for a `Stream` value. | |
167 | * | |
168 | * @param value A value for which a transformer is created. | |
169 | * @return A transformer for a {@code value}. | |
170 | * @see StreamTransformer | |
171 | */ | |
172 | static <E> | |
173 | StreamTransformer<Stream<E>, E> | |
174 | streamValue(Stream<E> value) { | |
175 |
2
1. lambda$streamValue$11 : replaced return value with Stream.empty for com/github/valid8j/pcond/fluent/Statement::lambda$streamValue$11 → KILLED 2. streamValue : replaced return value with null for com/github/valid8j/pcond/fluent/Statement::streamValue → KILLED |
return StreamTransformer.create(() -> value); |
176 | } | |
177 | ||
178 | /** | |
179 | * Returns a transformer for a {@link Throwable} value. | |
180 | * | |
181 | * @param value A value for which a transformer is created. | |
182 | * @return A transformer for a {@code value}. | |
183 | * @see ThrowableTransformer | |
184 | */ | |
185 | static <E extends Throwable> ThrowableTransformer<E, E> | |
186 | throwableValue(E value) { | |
187 |
2
1. lambda$throwableValue$12 : replaced return value with null for com/github/valid8j/pcond/fluent/Statement::lambda$throwableValue$12 → KILLED 2. throwableValue : replaced return value with null for com/github/valid8j/pcond/fluent/Statement::throwableValue → KILLED |
return ThrowableTransformer.create(() -> value); |
188 | } | |
189 | } | |
Mutations | ||
33 |
1.1 |
|
34 |
1.1 |
|
35 |
1.1 |
|
63 |
1.1 2.2 |
|
75 |
1.1 2.2 |
|
87 |
1.1 2.2 |
|
99 |
1.1 2.2 |
|
111 |
1.1 2.2 |
|
123 |
1.1 2.2 |
|
135 |
1.1 2.2 3.3 |
|
148 |
1.1 2.2 |
|
162 |
1.1 2.2 |
|
175 |
1.1 2.2 |
|
187 |
1.1 2.2 |