InputResolver.java

1
package com.github.valid8j.metamor;
2
3
import com.github.valid8j.pcond.core.printable.PrintableFunction;
4
import com.github.valid8j.pcond.forms.Printables;
5
6
import java.util.*;
7
import java.util.function.Function;
8
import java.util.function.Supplier;
9
10
import static java.util.Collections.emptyList;
11
import static java.util.Objects.requireNonNull;
12
import static java.util.stream.Collectors.joining;
13
import static java.util.stream.Collectors.toList;
14
15
public interface InputResolver<I, O> extends Function<Dataset<IoPair<I, O>>, I> {
16
  class Impl<I, O> extends PrintableFunction<Dataset<IoPair<I, O>>, I> implements InputResolver<I, O> {
17
    public Impl(Supplier<String> s, Function<? super Dataset<IoPair<I, O>>, ? extends I> function) {
18
      super(new Object(), emptyList(), s, function);
19
    }
20
  }
21
22
  interface Sequence<I, O> extends Dataset<InputResolver<I, O>> {
23
    class Impl<I, O> implements Sequence<I, O> {
24
25
      private final String inputVariableName;
26
      private final List<InputResolver<I, O>> inputResolvers;
27
28
      public Impl(String inputVariableName, List<InputResolver<I, O>> inputResolvers) {
29
        this.inputVariableName = requireNonNull(inputVariableName);
30
        this.inputResolvers = requireNonNull(inputResolvers);
31
      }
32
33
      @Override
34
      public InputResolver<I, O> get(int i) {
35 1 1. get : replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Impl::get → KILLED
        return inputResolvers.get(i);
36
      }
37
38
      @Override
39
      public int size() {
40 1 1. size : replaced int return with 0 for com/github/valid8j/metamor/InputResolver$Sequence$Impl::size → NO_COVERAGE
        return inputResolvers.size();
41
      }
42
43
      @Override
44
      public String name() {
45 1 1. name : replaced return value with "" for com/github/valid8j/metamor/InputResolver$Sequence$Impl::name → SURVIVED
        return this.inputVariableName;
46
      }
47
48
      @Override
49
      public String toString() {
50 1 1. toString : replaced return value with "" for com/github/valid8j/metamor/InputResolver$Sequence$Impl::toString → SURVIVED
        return inputVariableName + ":" + inputResolvers;
51
      }
52
53
      @Override
54
      public Iterator<InputResolver<I, O>> iterator() {
55 1 1. iterator : replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Impl::iterator → NO_COVERAGE
        return new AbstractList<InputResolver<I, O>>() {
56
57
          @Override
58
          public int size() {
59 1 1. size : replaced int return with 0 for com/github/valid8j/metamor/InputResolver$Sequence$Impl$1::size → NO_COVERAGE
            return Impl.this.size();
60
          }
61
62
          @Override
63
          public InputResolver<I, O> get(int index) {
64 1 1. get : replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Impl$1::get → NO_COVERAGE
            return Impl.this.get(index);
65
          }
66
        }.iterator();
67
      }
68
    }
69
70
    interface Factory<X, I, O> extends Function<X, Sequence<I, O>> {
71
      int count();
72
73
      class Impl<X, I, O>
74
          extends PrintableFunction<X, Sequence<I, O>>
75
          implements Factory<X, I, O> {
76
77
        private final int count;
78
79
        public Impl(Supplier<String> s, Function<? super X, ? extends Sequence<I, O>> function, int count) {
80
          super(new Object(), emptyList(), s, function);
81
          this.count = count;
82
        }
83
84
        public Impl(String inputVariableName, List<Function<? super X, ? extends InputResolver<I, O>>> functions) {
85
          this(
86
              () -> functions.stream()
87
                  .map(Objects::toString)
88 1 1. lambda$new$0 : replaced return value with "" for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Impl::lambda$new$0 → SURVIVED
                  .collect(joining(",", "[", "]")),
89
              Factory.Impl.toSequenceCreatorFunction(inputVariableName, functions), functions.size());
90
        }
91
92
        @Override
93
        public int count() {
94 1 1. count : replaced int return with 0 for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Impl::count → KILLED
          return this.count;
95
        }
96
97
        private static <X, I, O> Function<? super X, ? extends Sequence<I, O>> toSequenceCreatorFunction(String inputVariableName, List<Function<? super X, ? extends InputResolver<I, O>>> functions) {
98 2 1. lambda$toSequenceCreatorFunction$2 : replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Impl::lambda$toSequenceCreatorFunction$2 → KILLED
2. toSequenceCreatorFunction : replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Impl::toSequenceCreatorFunction → KILLED
          return (X value) -> new Sequence.Impl<>(
99
              inputVariableName,
100
              functions.stream()
101 1 1. lambda$null$1 : replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Impl::lambda$null$1 → KILLED
                  .map(f -> f.apply(value))
102
                  .collect(toList()));
103
        }
104
      }
105
106
      class Builder<X, I, O> {
107
        private final List<Function<? super X, ? extends InputResolver<I, O>>> functions = new LinkedList<>();
108
        private final String                                                   placeHolderVariableName;
109
        private final String inputVariableName;
110
111
        public Builder(String inputVariableName, String placeHolderVariableName) {
112
          this.placeHolderVariableName = placeHolderVariableName;
113
          this.inputVariableName = inputVariableName;
114
        }
115
116
        public Builder<X, I, O> function(Function<Object, String> formatter, Function<X, I> f) {
117 4 1. lambda$function$0 : replaced return value with "" for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Builder::lambda$function$0 → SURVIVED
2. lambda$null$1 : replaced return value with "" for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Builder::lambda$null$1 → SURVIVED
3. lambda$function$3 : replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Builder::lambda$function$3 → KILLED
4. lambda$null$2 : replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Builder::lambda$null$2 → KILLED
          this.functions.add(Printables.function(() -> formatter.apply(this.placeHolderVariableName), x -> new InputResolver.Impl<>(() -> formatter.apply(x), ds -> f.apply(x))));
118 1 1. function : replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Builder::function → KILLED
          return this;
119
        }
120
121
        public Factory<X, I, O> build() {
122 1 1. build : replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Builder::build → KILLED
          return new Impl<>(this.inputVariableName, this.functions);
123
        }
124
      }
125
    }
126
  }
127
}

Mutations

35

1.1
Location : get
Killed by : com.github.valid8j.examples.test.ExamplesTest.testMetarmorExamplePassing(com.github.valid8j.examples.test.ExamplesTest)
replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Impl::get → KILLED

40

1.1
Location : size
Killed by : none
replaced int return with 0 for com/github/valid8j/metamor/InputResolver$Sequence$Impl::size → NO_COVERAGE

45

1.1
Location : name
Killed by : none
replaced return value with "" for com/github/valid8j/metamor/InputResolver$Sequence$Impl::name → SURVIVED

50

1.1
Location : toString
Killed by : none
replaced return value with "" for com/github/valid8j/metamor/InputResolver$Sequence$Impl::toString → SURVIVED

55

1.1
Location : iterator
Killed by : none
replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Impl::iterator → NO_COVERAGE

59

1.1
Location : size
Killed by : none
replaced int return with 0 for com/github/valid8j/metamor/InputResolver$Sequence$Impl$1::size → NO_COVERAGE

64

1.1
Location : get
Killed by : none
replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Impl$1::get → NO_COVERAGE

88

1.1
Location : lambda$new$0
Killed by : none
replaced return value with "" for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Impl::lambda$new$0 → SURVIVED

94

1.1
Location : count
Killed by : com.github.valid8j.examples.test.ExamplesTest.testMetarmorExamplePassing(com.github.valid8j.examples.test.ExamplesTest)
replaced int return with 0 for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Impl::count → KILLED

98

1.1
Location : lambda$toSequenceCreatorFunction$2
Killed by : com.github.valid8j.examples.test.ExamplesTest.testMetarmorExamplePassing(com.github.valid8j.examples.test.ExamplesTest)
replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Impl::lambda$toSequenceCreatorFunction$2 → KILLED

2.2
Location : toSequenceCreatorFunction
Killed by : com.github.valid8j.examples.test.ExamplesTest.testMetarmorExamplePassing(com.github.valid8j.examples.test.ExamplesTest)
replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Impl::toSequenceCreatorFunction → KILLED

101

1.1
Location : lambda$null$1
Killed by : com.github.valid8j.examples.test.ExamplesTest.testMetarmorExamplePassing(com.github.valid8j.examples.test.ExamplesTest)
replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Impl::lambda$null$1 → KILLED

117

1.1
Location : lambda$function$0
Killed by : none
replaced return value with "" for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Builder::lambda$function$0 → SURVIVED

2.2
Location : lambda$function$3
Killed by : com.github.valid8j.examples.test.ExamplesTest.testMetarmorExamplePassing(com.github.valid8j.examples.test.ExamplesTest)
replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Builder::lambda$function$3 → KILLED

3.3
Location : lambda$null$1
Killed by : none
replaced return value with "" for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Builder::lambda$null$1 → SURVIVED

4.4
Location : lambda$null$2
Killed by : com.github.valid8j.examples.test.ExamplesTest.testMetarmorExamplePassing(com.github.valid8j.examples.test.ExamplesTest)
replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Builder::lambda$null$2 → KILLED

118

1.1
Location : function
Killed by : com.github.valid8j.examples.test.ExamplesTest.testMetarmorExamplePassing(com.github.valid8j.examples.test.ExamplesTest)
replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Builder::function → KILLED

122

1.1
Location : build
Killed by : com.github.valid8j.examples.test.ExamplesTest.testMetarmorExamplePassing(com.github.valid8j.examples.test.ExamplesTest)
replaced return value with null for com/github/valid8j/metamor/InputResolver$Sequence$Factory$Builder::build → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3