DistinctUntilChangedGatherer.java

1
package com.pivovarit.gatherers;
2
3
import java.util.Objects;
4
import java.util.function.Function;
5
import java.util.function.Supplier;
6
import java.util.stream.Gatherer;
7
8
record DistinctUntilChangedGatherer<T, U>(
9
  Function<? super T, ? extends U> keyExtractor) implements Gatherer<T, DistinctUntilChangedGatherer.State<U>, T> {
10
11
    DistinctUntilChangedGatherer {
12
        Objects.requireNonNull(keyExtractor, "keyExtractor can't be null");
13
    }
14
15
    @Override
16
    public Supplier<State<U>> initializer() {
17 1 1. initializer : replaced return value with null for com/pivovarit/gatherers/DistinctUntilChangedGatherer::initializer → KILLED
        return State::new;
18
    }
19
20
    @Override
21
    public Integrator<State<U>, T, T> integrator() {
22 1 1. integrator : replaced return value with null for com/pivovarit/gatherers/DistinctUntilChangedGatherer::integrator → KILLED
        return (state, element, downstream) -> {
23
            U key = keyExtractor.apply(element);
24 2 1. lambda$integrator$0 : negated conditional → KILLED
2. lambda$integrator$0 : negated conditional → KILLED
            if (!state.hasValue || !Objects.equals(state.value, key)) {
25
                state.value = key;
26
                state.hasValue = true;
27 2 1. lambda$integrator$0 : replaced boolean return with true for com/pivovarit/gatherers/DistinctUntilChangedGatherer::lambda$integrator$0 → SURVIVED
2. lambda$integrator$0 : replaced boolean return with false for com/pivovarit/gatherers/DistinctUntilChangedGatherer::lambda$integrator$0 → KILLED
                return downstream.push(element);
28
            }
29 1 1. lambda$integrator$0 : replaced boolean return with false for com/pivovarit/gatherers/DistinctUntilChangedGatherer::lambda$integrator$0 → KILLED
            return true;
30
        };
31
    }
32
33
    static class State<U> {
34
        U value;
35
        boolean hasValue;
36
    }
37
}

Mutations

17

1.1
Location : initializer
Killed by : com.pivovarit.gatherers.blackbox.DistinctUntilChangedMapperTest.[engine:junit-jupiter]/[class:com.pivovarit.gatherers.blackbox.DistinctUntilChangedMapperTest]/[method:shouldDistinctUntilChangedEmptyStream()]
replaced return value with null for com/pivovarit/gatherers/DistinctUntilChangedGatherer::initializer → KILLED

22

1.1
Location : integrator
Killed by : com.pivovarit.gatherers.blackbox.DistinctUntilChangedMapperTest.[engine:junit-jupiter]/[class:com.pivovarit.gatherers.blackbox.DistinctUntilChangedMapperTest]/[method:shouldDistinctUntilChangedMapper()]
replaced return value with null for com/pivovarit/gatherers/DistinctUntilChangedGatherer::integrator → KILLED

24

1.1
Location : lambda$integrator$0
Killed by : com.pivovarit.gatherers.blackbox.DistinctUntilChangedMapperTest.[engine:junit-jupiter]/[class:com.pivovarit.gatherers.blackbox.DistinctUntilChangedMapperTest]/[method:shouldDistinctUntilChangedMapper()]
negated conditional → KILLED

2.2
Location : lambda$integrator$0
Killed by : com.pivovarit.gatherers.blackbox.DistinctUntilChangedMapperTest.[engine:junit-jupiter]/[class:com.pivovarit.gatherers.blackbox.DistinctUntilChangedMapperTest]/[method:shouldDistinctUntilChangedMapper()]
negated conditional → KILLED

27

1.1
Location : lambda$integrator$0
Killed by : com.pivovarit.gatherers.blackbox.DistinctUntilChangedMapperTest.[engine:junit-jupiter]/[class:com.pivovarit.gatherers.blackbox.DistinctUntilChangedMapperTest]/[method:shouldDistinctUntilChangedMapper()]
replaced boolean return with false for com/pivovarit/gatherers/DistinctUntilChangedGatherer::lambda$integrator$0 → KILLED

2.2
Location : lambda$integrator$0
Killed by : none
replaced boolean return with true for com/pivovarit/gatherers/DistinctUntilChangedGatherer::lambda$integrator$0 → SURVIVED
Covering tests

29

1.1
Location : lambda$integrator$0
Killed by : com.pivovarit.gatherers.blackbox.DistinctUntilChangedMapperTest.[engine:junit-jupiter]/[class:com.pivovarit.gatherers.blackbox.DistinctUntilChangedMapperTest]/[method:shouldDistinctUntilChangedMapper()]
replaced boolean return with false for com/pivovarit/gatherers/DistinctUntilChangedGatherer::lambda$integrator$0 → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.1