PlaceholderFinder.java

1
package pro.verron.officestamper.core;
2
3
import pro.verron.officestamper.api.Placeholder;
4
5
import java.util.ArrayList;
6
import java.util.List;
7
import java.util.regex.Pattern;
8
9
import static java.util.Collections.emptyList;
10
11
/**
12
 * The ExpressionFinder class is responsible
13
 * for finding expressions in a given text based on a specified pattern and matcher.
14
 * It uses the Matcher class
15
 * to determine if an expression matches the specified prefix and suffix,
16
 * and the Expression class to represent each found expression.
17
 */
18
public record PlaceholderFinder(
19
        Pattern pattern,
20
        Matcher matcher
21
) {
22
    /**
23
     * Finds expressions in a given text based on a specified pattern and matcher.
24
     *
25
     * @param text the text to search for expressions
26
     * @return a list of found expressions
27
     */
28
    public List<Placeholder> find(String text) {
29 1 1. find : negated conditional → KILLED
        if (text.isEmpty())
30
            return emptyList();
31
        var matcher = pattern.matcher(text);
32
        int index = 0;
33
        List<Placeholder> matches = new ArrayList<>();
34 1 1. find : negated conditional → KILLED
        while (matcher.find(index)) {
35
            String match = matcher.group();
36
            matches.add(new StandardPlaceholder(this.matcher, match));
37
            index = matcher.end();
38
        }
39 1 1. find : replaced return value with Collections.emptyList for pro/verron/officestamper/core/PlaceholderFinder::find → KILLED
        return matches;
40
    }
41
}

Mutations

29

1.1
Location : find
Killed by : pro.verron.officestamper.test.ResolutionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ResolutionTest]/[test-template:testCustomResolution(java.lang.String, boolean, boolean, boolean, boolean, boolean, java.lang.String, boolean, java.lang.String)]/[test-template-invocation:#30]
negated conditional → KILLED

34

1.1
Location : find
Killed by : pro.verron.officestamper.test.ResolutionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ResolutionTest]/[test-template:testCustomResolution(java.lang.String, boolean, boolean, boolean, boolean, boolean, java.lang.String, boolean, java.lang.String)]/[test-template-invocation:#30]
negated conditional → KILLED

39

1.1
Location : find
Killed by : pro.verron.officestamper.test.ResolutionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ResolutionTest]/[test-template:testCustomResolution(java.lang.String, boolean, boolean, boolean, boolean, boolean, java.lang.String, boolean, java.lang.String)]/[test-template-invocation:#30]
replaced return value with Collections.emptyList for pro/verron/officestamper/core/PlaceholderFinder::find → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.1