PlaceholderFinder.java

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

Mutations

25

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

29

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

34

1.1
Location : find
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/PlaceholderFinder::find → KILLED

Active mutators

Tests examined


Report generated by PIT 1.25.5 support