Skip to content

Commit 5d57100

Browse files
committed
Polishing.
Use extended switch syntax. See #4404 Original pull request: #4412
1 parent 57688d8 commit 5d57100

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/MongoRegexCreator.java

+7-12
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,13 @@ public String toRegularExpression(@Nullable String source, @Nullable MatchMode m
8989

9090
String regex = prepareAndEscapeStringBeforeApplyingLikeRegex(source, matcherType);
9191

92-
switch (matcherType) {
93-
case STARTING_WITH:
94-
return String.format("^%s", regex);
95-
case ENDING_WITH:
96-
return String.format("%s$", regex);
97-
case CONTAINING:
98-
return String.format(".*%s.*", regex);
99-
case EXACT:
100-
return String.format("^%s$", regex);
101-
default:
102-
return regex;
103-
}
92+
return switch (matcherType) {
93+
case STARTING_WITH -> String.format("^%s", regex);
94+
case ENDING_WITH -> String.format("%s$", regex);
95+
case CONTAINING -> String.format(".*%s.*", regex);
96+
case EXACT -> String.format("^%s$", regex);
97+
default -> regex;
98+
};
10499
}
105100

106101
/**

0 commit comments

Comments
 (0)