PowerpointCollector.java

1
package pro.verron.officestamper.experimental;
2
3
4
import org.jspecify.annotations.Nullable;
5
6
import java.util.ArrayList;
7
import java.util.List;
8
9
/// The PowerpointCollector class is used to collect instances of a specific class in a PowerPoint presentation.
10
///
11
/// @param <T> the type of instances to collect
12
public class PowerpointCollector<T>
13
        extends PowerpointVisitor {
14
    private final Class<T> aClass;
15
    private final List<T> list = new ArrayList<>();
16
17
    /// The PowerpointCollector class is used to collect instances of a specific class in a PowerPoint presentation.
18
    ///
19
    /// @param aClass the type of instances to collect
20
    public PowerpointCollector(Class<T> aClass) {
21
        this.aClass = aClass;
22
    }
23
24
    /// Collects instances of a specific class in a PowerPoint presentation.
25
    ///
26
    /// @param <T>      the type of instances to collect
27
    /// @param template the PowerPoint presentation template
28
    /// @param aClass   the type of instances to collect
29
    ///
30
    /// @return a list of instances of the specified class
31
    public static <T> List<T> collect(
32
            Object template,
33
            Class<T> aClass
34
    ) {
35
        var collector = new PowerpointCollector<>(aClass);
36 1 1. collect : removed call to pro/verron/officestamper/experimental/PowerpointCollector::visit → KILLED
        collector.visit(template);
37 1 1. collect : replaced return value with Collections.emptyList for pro/verron/officestamper/experimental/PowerpointCollector::collect → KILLED
        return collector.collect();
38
    }
39
40
    /// Retrieves the collected instances of a specific class.
41
    ///
42
    /// @return an instance list of the specified class
43
    public List<T> collect() {
44 1 1. collect : replaced return value with Collections.emptyList for pro/verron/officestamper/experimental/PowerpointCollector::collect → KILLED
        return list;
45
    }
46
47
    @Override
48
    protected void before(@Nullable Object object) {
49 1 1. before : negated conditional → KILLED
        if (aClass.isInstance(object))
50
            list.add(aClass.cast(object));
51
    }
52
}

Mutations

36

1.1
Location : collect
Killed by : pro.verron.officestamper.test.BasicPowerpointTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.BasicPowerpointTest]/[method:testStamper()]
removed call to pro/verron/officestamper/experimental/PowerpointCollector::visit → KILLED

37

1.1
Location : collect
Killed by : pro.verron.officestamper.test.BasicPowerpointTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.BasicPowerpointTest]/[method:testStamper()]
replaced return value with Collections.emptyList for pro/verron/officestamper/experimental/PowerpointCollector::collect → KILLED

44

1.1
Location : collect
Killed by : pro.verron.officestamper.test.BasicPowerpointTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.BasicPowerpointTest]/[method:testStamper()]
replaced return value with Collections.emptyList for pro/verron/officestamper/experimental/PowerpointCollector::collect → KILLED

49

1.1
Location : before
Killed by : pro.verron.officestamper.test.BasicPowerpointTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.BasicPowerpointTest]/[method:testStamper()]
negated conditional → KILLED

Active mutators

Tests examined


Report generated by PIT 1.22.0