PowerpointCollector.java

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

Mutations

40

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

41

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

50

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

55

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.17.0