| 1 | package pro.verron.officestamper.core; | |
| 2 | ||
| 3 | ||
| 4 | /// The Matcher class provides methods to match and strip expressions based on a specified prefix and suffix. | |
| 5 | /// The match() method checks if an expression starts with the prefix | |
| 6 | /// and ends with the suffix. | |
| 7 | /// The strip() method removes the prefix and suffix from an expression | |
| 8 | /// and returns the inner part. | |
| 9 | /// | |
| 10 | /// @param prefix the prefix to match. | |
| 11 | /// @param suffix the suffix to match. | |
| 12 | public record Matcher(String prefix, String suffix) { | |
| 13 | ||
| 14 | /// Checks if the given expression matches the specified criteria. | |
| 15 | /// | |
| 16 | /// @param expression the expression to be matched. | |
| 17 | /// @return `true` if the expression starts with the prefix | |
| 18 | /// and ends with the suffix, `false` otherwise. | |
| 19 | public boolean match(String expression) { | |
| 20 |
3
1. match : replaced boolean return with true for pro/verron/officestamper/core/Matcher::match → SURVIVED 2. match : negated conditional → KILLED 3. match : negated conditional → KILLED |
return expression.startsWith(prefix) && expression.endsWith(suffix); |
| 21 | } | |
| 22 | ||
| 23 | /// Strips the prefix and suffix from the given expression and returns the inner part. | |
| 24 | /// | |
| 25 | /// @param expression the expression to be stripped. | |
| 26 | /// @return the inner part of the expression after stripping the prefix and suffix. | |
| 27 | public String strip(String expression) { | |
| 28 | int start = prefix.length(); | |
| 29 |
1
1. strip : Replaced integer subtraction with addition → KILLED |
int end = expression.length() - suffix.length(); |
| 30 |
1
1. strip : replaced return value with "" for pro/verron/officestamper/core/Matcher::strip → KILLED |
return expression.substring(start, end); |
| 31 | } | |
| 32 | } | |
Mutations | ||
| 20 |
1.1 2.2 3.3 |
|
| 29 |
1.1 |
|
| 30 |
1.1 |