1 | package com.github.valid8j.metamor; | |
2 | ||
3 | import com.github.valid8j.pcond.core.printable.PrintableFunction; | |
4 | ||
5 | import java.util.function.Function; | |
6 | import java.util.function.IntFunction; | |
7 | import java.util.function.Predicate; | |
8 | import java.util.stream.IntStream; | |
9 | ||
10 | import static java.util.Collections.emptyList; | |
11 | import static java.util.Objects.requireNonNull; | |
12 | ||
13 | public interface Proposition { | |
14 | boolean evaluate(); | |
15 | ||
16 | int arity(); | |
17 | ||
18 | class Impl<X> implements Proposition { | |
19 | final Function<Object[], String> formatter; | |
20 | private final Predicate<Dataset<X>> predicate; | |
21 | private final Dataset<X> dataset; | |
22 | ||
23 | public Impl(Predicate<Dataset<X>> predicate, Function<Object[], String> formatter, Dataset<X> dataset) { | |
24 | this.predicate = predicate; | |
25 | this.formatter = requireNonNull(formatter); | |
26 | this.dataset = requireNonNull(dataset); | |
27 | } | |
28 | ||
29 | @Override | |
30 | public boolean evaluate() { | |
31 |
2
1. evaluate : replaced boolean return with false for com/github/valid8j/metamor/Proposition$Impl::evaluate → KILLED 2. evaluate : replaced boolean return with true for com/github/valid8j/metamor/Proposition$Impl::evaluate → KILLED |
return this.predicate.test(this.dataset); |
32 | } | |
33 | ||
34 | @Override | |
35 | public int arity() { | |
36 |
1
1. arity : replaced int return with 0 for com/github/valid8j/metamor/Proposition$Impl::arity → SURVIVED |
return this.dataset.size(); |
37 | } | |
38 | ||
39 | @Override | |
40 | public String toString() { | |
41 |
1
1. toString : replaced return value with "" for com/github/valid8j/metamor/Proposition$Impl::toString → SURVIVED |
return this.formatter.apply(IntStream.range(0, this.arity()) |
42 | .mapToObj(dataset::get) | |
43 | .toArray()); | |
44 | } | |
45 | } | |
46 | ||
47 | interface Factory<X> extends Function<Dataset<X>, Proposition> { | |
48 | ||
49 | static <X> Factory<X> create(Predicate<Dataset<X>> predicate, Function<Object[], String> formatter, IntFunction<String> placeHolderFormatter, int arity) { | |
50 |
1
1. create : replaced return value with null for com/github/valid8j/metamor/Proposition$Factory::create → KILLED |
return new Impl<>(predicate, formatter, placeHolderFormatter, arity); |
51 | } | |
52 | ||
53 | class Impl<X> extends PrintableFunction<Dataset<X>, Proposition> implements Factory<X> { | |
54 | ||
55 | protected Impl(Predicate<Dataset<X>> predicate, Function<Object[], String> formatter, IntFunction<String> placeHolderFormatter, int arity) { | |
56 | super( | |
57 | new Object(), | |
58 | emptyList(), | |
59 |
1
1. lambda$new$0 : replaced return value with "" for com/github/valid8j/metamor/Proposition$Factory$Impl::lambda$new$0 → SURVIVED |
() -> formatter.apply(IntStream.range(0, arity).mapToObj(placeHolderFormatter).toArray()), |
60 |
1
1. lambda$new$1 : replaced return value with null for com/github/valid8j/metamor/Proposition$Factory$Impl::lambda$new$1 → KILLED |
ds -> new Proposition.Impl<>(predicate, formatter, ds)); |
61 | } | |
62 | ||
63 | @Override | |
64 | public Proposition apply(Dataset<X> ds) { | |
65 |
1
1. apply : replaced return value with null for com/github/valid8j/metamor/Proposition$Factory$Impl::apply → KILLED |
return super.apply(ds); |
66 | } | |
67 | } | |
68 | } | |
69 | } | |
Mutations | ||
31 |
1.1 2.2 |
|
36 |
1.1 |
|
41 |
1.1 |
|
50 |
1.1 |
|
59 |
1.1 |
|
60 |
1.1 |
|
65 |
1.1 |