Skip to content

Commit f635de7

Browse files
committed
Polishing.
Refine conditional flow. See #3932
1 parent f92b40c commit f635de7

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/ParameterBinding.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,6 @@ static class LikeParameterBinding extends ParameterBinding {
231231
private static final List<Type> SUPPORTED_TYPES = Arrays.asList(Type.CONTAINING, Type.STARTING_WITH,
232232
Type.ENDING_WITH, Type.LIKE);
233233

234-
private static final String PERCENT = "%";
235-
236234
private final Type type;
237235

238236
/**
@@ -328,15 +326,11 @@ static Type getLikeTypeFrom(String expression) {
328326

329327
Assert.hasText(expression, "Expression must not be null or empty");
330328

331-
if (expression.startsWith(PERCENT) && expression.endsWith(PERCENT)) {
332-
return Type.CONTAINING;
333-
}
334-
335-
if (expression.startsWith(PERCENT)) {
336-
return Type.ENDING_WITH;
329+
if (expression.startsWith("%")) {
330+
return expression.endsWith("%") ? Type.CONTAINING : Type.ENDING_WITH;
337331
}
338332

339-
if (expression.endsWith(PERCENT)) {
333+
if (expression.endsWith("%")) {
340334
return Type.STARTING_WITH;
341335
}
342336

0 commit comments

Comments
 (0)