DistinctByGatherer.java

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

Mutations

17

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

22

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

23

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

24

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

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

26

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

Active mutators

Tests examined


Report generated by PIT 1.17.1