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