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
    /// @return a list of instances of the specified class
30
    public static <T> List<T> collect(
31
            Object template,
32
            Class<T> aClass
33
    ) {
34
        var collector = new PowerpointCollector<>(aClass);
35 1 1. collect : removed call to pro/verron/officestamper/experimental/PowerpointCollector::visit → KILLED
        collector.visit(template);
36 1 1. collect : replaced return value with Collections.emptyList for pro/verron/officestamper/experimental/PowerpointCollector::collect → KILLED
        return collector.collect();
37
    }
38
39
    /// Retrieves the collected instances of a specific class.
40
    ///
41
    /// @return an instance list of the specified class
42
    public List<T> collect() {
43 1 1. collect : replaced return value with Collections.emptyList for pro/verron/officestamper/experimental/PowerpointCollector::collect → KILLED
        return list;
44
    }
45
46
    @Override
47
    protected void before(@Nullable Object object) {
48 1 1. before : negated conditional → KILLED
        if (aClass.isInstance(object))
49
            list.add(aClass.cast(object));
50
    }
51
}

Mutations

35

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

36

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

43

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

48

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

Active mutators

Tests examined


Report generated by PIT 1.25.5 support