| 1 | package com.github.dakusui.pcond.core.printable; | |
| 2 | ||
| 3 | import com.github.dakusui.pcond.core.Evaluable; | |
| 4 | import com.github.dakusui.pcond.core.identifieable.Identifiable; | |
| 5 | import com.github.dakusui.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 | ||
| 17 |   protected PrintablePredicate(Object creator, List<Object> args, Supplier<String> formatter, Predicate<? super T> predicate) { | |
| 18 |     super(creator, args); | |
| 19 |     this.formatter = Objects.requireNonNull(formatter); | |
| 20 |     this.predicate = requireNonPrintablePredicate(unwrap(Objects.requireNonNull(predicate))); | |
| 21 |   } | |
| 22 | ||
| 23 |   @Override | |
| 24 |   public boolean test(T t) { | |
| 25 | 2
1. test : replaced boolean return with false for com/github/dakusui/pcond/core/printable/PrintablePredicate::test → KILLED 2. test : replaced boolean return with true for com/github/dakusui/pcond/core/printable/PrintablePredicate::test → KILLED |     return this.predicate.test(t); | 
| 26 |   } | |
| 27 | ||
| 28 |   @Override | |
| 29 |   public String toString() { | |
| 30 | 1
1. toString : replaced return value with "" for com/github/dakusui/pcond/core/printable/PrintablePredicate::toString → KILLED |     return formatter.get(); | 
| 31 |   } | |
| 32 | ||
| 33 |   @Override | |
| 34 |   public Predicate<T> and(Predicate<? super T> other) { | |
| 35 | 1
1. and : replaced return value with null for com/github/dakusui/pcond/core/printable/PrintablePredicate::and → KILLED |     return Predicates.and(this, other); | 
| 36 |   } | |
| 37 | ||
| 38 |   @Override | |
| 39 |   public Predicate<T> or(Predicate<? super T> other) { | |
| 40 | 1
1. or : replaced return value with null for com/github/dakusui/pcond/core/printable/PrintablePredicate::or → KILLED |     return Predicates.or(this, other); | 
| 41 |   } | |
| 42 | ||
| 43 |   @Override | |
| 44 |   public Predicate<T> negate() { | |
| 45 | 1
1. negate : replaced return value with null for com/github/dakusui/pcond/core/printable/PrintablePredicate::negate → KILLED |     return PrintablePredicateFactory.not(this); | 
| 46 |   } | |
| 47 | ||
| 48 |   @SuppressWarnings("unchecked") | |
| 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/dakusui/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/dakusui/pcond/core/printable/PrintablePredicate::clone → KILLED |       return (PrintablePredicate<T>) super.clone(); | 
| 63 |     } catch (CloneNotSupportedException e) { | |
| 64 |       throw new AssertionError(); | |
| 65 |     } | |
| 66 |   } | |
| 67 | ||
| 68 | ||
| 69 |   public boolean isSquashable() { | |
| 70 | 2
1. isSquashable : replaced boolean return with false for com/github/dakusui/pcond/core/printable/PrintablePredicate::isSquashable → SURVIVED 2. isSquashable : replaced boolean return with true for com/github/dakusui/pcond/core/printable/PrintablePredicate::isSquashable → SURVIVED |     return this.squashable; | 
| 71 |   } | |
| 72 | ||
| 73 |   @Override | |
| 74 |   public PrintablePredicate<T> makeTrivial() { | |
| 75 |     PrintablePredicate<T> ret = this.clone(); | |
| 76 |     ret.squashable = true; | |
| 77 | 1
1. makeTrivial : replaced return value with null for com/github/dakusui/pcond/core/printable/PrintablePredicate::makeTrivial → KILLED |     return ret; | 
| 78 |   } | |
| 79 | ||
| 80 |   private static <T> Predicate<T> requireNonPrintablePredicate(Predicate<T> predicate) { | |
| 81 |     assert !(predicate instanceof PrintablePredicate); | |
| 82 | 1
1. requireNonPrintablePredicate : replaced return value with null for com/github/dakusui/pcond/core/printable/PrintablePredicate::requireNonPrintablePredicate → KILLED |     return predicate; | 
| 83 |   } | |
| 84 | } | |
| Mutations | ||
| 25 | 1.1 2.2 | |
| 30 | 1.1 | |
| 35 | 1.1 | |
| 40 | 1.1 | |
| 45 | 1.1 | |
| 51 | 1.1 | |
| 55 | 1.1 | |
| 62 | 1.1 | |
| 70 | 1.1 2.2 | |
| 77 | 1.1 | |
| 82 | 1.1 |