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