| 1 | package com.github.valid8j.pcond.core.printable; | |
| 2 | ||
| 3 | import com.github.valid8j.pcond.core.identifieable.Identifiable; | |
| 4 | import com.github.valid8j.pcond.core.Evaluable; | |
| 5 | import com.github.valid8j.pcond.forms.Predicates; | |
| 6 | ||
| 7 | import java.util.List; | |
| 8 | import java.util.Objects; | |
| 9 | import java.util.function.Predicate; | |
| 10 | import java.util.function.Supplier; | |
| 11 | ||
| 12 | public abstract class PrintablePredicate<T> extends Identifiable.Base implements Predicate<T>, Evaluable<T>, Cloneable { | |
| 13 | protected final Predicate<? super T> predicate; | |
| 14 | final Supplier<String> formatter; | |
| 15 | boolean squashable = false; | |
| 16 | private boolean trivial = false; | |
| 17 | ||
| 18 | protected PrintablePredicate(Object creator, List<Object> args, Supplier<String> formatter, Predicate<? super T> predicate) { | |
| 19 | super(creator, args); | |
| 20 | this.formatter = Objects.requireNonNull(formatter); | |
| 21 | this.predicate = requireNonPrintablePredicate(unwrap(Objects.requireNonNull(predicate))); | |
| 22 | } | |
| 23 | ||
| 24 | @Override | |
| 25 | public boolean test(T t) { | |
| 26 |
2
1. test : replaced boolean return with false for com/github/valid8j/pcond/core/printable/PrintablePredicate::test → KILLED 2. test : replaced boolean return with true for com/github/valid8j/pcond/core/printable/PrintablePredicate::test → KILLED |
return this.predicate.test(t); |
| 27 | } | |
| 28 | ||
| 29 | @Override | |
| 30 | public String toString() { | |
| 31 |
1
1. toString : replaced return value with "" for com/github/valid8j/pcond/core/printable/PrintablePredicate::toString → KILLED |
return formatter.get(); |
| 32 | } | |
| 33 | ||
| 34 | @Override | |
| 35 | public Predicate<T> and(Predicate<? super T> other) { | |
| 36 |
1
1. and : replaced return value with null for com/github/valid8j/pcond/core/printable/PrintablePredicate::and → KILLED |
return Predicates.and(this, other); |
| 37 | } | |
| 38 | ||
| 39 | @Override | |
| 40 | public Predicate<T> or(Predicate<? super T> other) { | |
| 41 |
1
1. or : replaced return value with null for com/github/valid8j/pcond/core/printable/PrintablePredicate::or → KILLED |
return Predicates.or(this, other); |
| 42 | } | |
| 43 | ||
| 44 | @Override | |
| 45 | public Predicate<T> negate() { | |
| 46 |
1
1. negate : replaced return value with null for com/github/valid8j/pcond/core/printable/PrintablePredicate::negate → KILLED |
return PrintablePredicateFactory.not(this); |
| 47 | } | |
| 48 | ||
| 49 | static <T> Predicate<? super T> unwrap(Predicate<? super T> predicate) { | |
| 50 | Predicate<? super T> ret = predicate; | |
| 51 |
1
1. unwrap : negated conditional → KILLED |
if (predicate instanceof PrintablePredicate) { |
| 52 | ret = ((PrintablePredicate<? super T>) predicate).predicate; | |
| 53 | assert !(ret instanceof PrintablePredicate); | |
| 54 | } | |
| 55 |
1
1. unwrap : replaced return value with null for com/github/valid8j/pcond/core/printable/PrintablePredicate::unwrap → KILLED |
return ret; |
| 56 | } | |
| 57 | ||
| 58 | @SuppressWarnings({ "CloneDoesntDeclareCloneNotSupportedException", "unchecked" }) | |
| 59 | @Override | |
| 60 | protected PrintablePredicate<T> clone() { | |
| 61 | try { | |
| 62 |
1
1. clone : replaced return value with null for com/github/valid8j/pcond/core/printable/PrintablePredicate::clone → KILLED |
return (PrintablePredicate<T>) super.clone(); |
| 63 | } catch (CloneNotSupportedException e) { | |
| 64 | throw new AssertionError(); | |
| 65 | } | |
| 66 | } | |
| 67 | ||
| 68 | ||
| 69 | @Override | |
| 70 | public boolean isSquashable() { | |
| 71 |
2
1. isSquashable : replaced boolean return with false for com/github/valid8j/pcond/core/printable/PrintablePredicate::isSquashable → SURVIVED 2. isSquashable : replaced boolean return with true for com/github/valid8j/pcond/core/printable/PrintablePredicate::isSquashable → SURVIVED |
return this.squashable; |
| 72 | } | |
| 73 | ||
| 74 | @Override | |
| 75 | public boolean isTrivial() { | |
| 76 |
2
1. isTrivial : replaced boolean return with false for com/github/valid8j/pcond/core/printable/PrintablePredicate::isTrivial → SURVIVED 2. isTrivial : replaced boolean return with true for com/github/valid8j/pcond/core/printable/PrintablePredicate::isTrivial → KILLED |
return this.trivial; |
| 77 | } | |
| 78 | ||
| 79 | @Override | |
| 80 | public PrintablePredicate<T> markSquashable() { | |
| 81 | PrintablePredicate<T> ret = this.clone(); | |
| 82 | ret.squashable = true; | |
| 83 |
1
1. markSquashable : replaced return value with null for com/github/valid8j/pcond/core/printable/PrintablePredicate::markSquashable → NO_COVERAGE |
return ret; |
| 84 | } | |
| 85 | ||
| 86 | @Override | |
| 87 | public PrintablePredicate<T> markTrivial() { | |
| 88 | PrintablePredicate<T> ret = this.clone(); | |
| 89 | ret.trivial = true; | |
| 90 |
1
1. markTrivial : replaced return value with null for com/github/valid8j/pcond/core/printable/PrintablePredicate::markTrivial → KILLED |
return ret; |
| 91 | } | |
| 92 | ||
| 93 | private static <T> Predicate<T> requireNonPrintablePredicate(Predicate<T> predicate) { | |
| 94 | assert !(predicate instanceof PrintablePredicate); | |
| 95 |
1
1. requireNonPrintablePredicate : replaced return value with null for com/github/valid8j/pcond/core/printable/PrintablePredicate::requireNonPrintablePredicate → KILLED |
return predicate; |
| 96 | } | |
| 97 | } | |
Mutations | ||
| 26 |
1.1 2.2 |
|
| 31 |
1.1 |
|
| 36 |
1.1 |
|
| 41 |
1.1 |
|
| 46 |
1.1 |
|
| 51 |
1.1 |
|
| 55 |
1.1 |
|
| 62 |
1.1 |
|
| 71 |
1.1 2.2 |
|
| 76 |
1.1 2.2 |
|
| 83 |
1.1 |
|
| 90 |
1.1 |
|
| 95 |
1.1 |