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