Skip to content

Commit 180b7ed

Browse files
committed
Polishing: JdbcQueryLookupStrategy
1 parent 8c017fc commit 180b7ed

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/JdbcQueryLookupStrategy.java

+12-16
Original file line numberDiff line numberDiff line change
@@ -299,22 +299,18 @@ public static QueryLookupStrategy create(@Nullable Key key, ApplicationEventPubl
299299
DeclaredQueryLookupStrategy declaredQueryLookupStrategy = new DeclaredQueryLookupStrategy(publisher, callbacks,
300300
context, converter, dialect, queryMappingConfiguration, operations, beanFactory, delegate);
301301

302-
Key keyToUse = key != null ? key : Key.CREATE_IF_NOT_FOUND;
303-
304-
LOG.debug(String.format("Using the queryLookupStrategy %s", keyToUse));
305-
306-
switch (keyToUse) {
307-
case CREATE:
308-
return createQueryLookupStrategy;
309-
case USE_DECLARED_QUERY:
310-
return declaredQueryLookupStrategy;
311-
case CREATE_IF_NOT_FOUND:
312-
return new CreateIfNotFoundQueryLookupStrategy(publisher, callbacks, context, converter, dialect,
313-
queryMappingConfiguration, operations, createQueryLookupStrategy, declaredQueryLookupStrategy,
314-
delegate);
315-
default:
316-
throw new IllegalArgumentException(String.format("Unsupported query lookup strategy %s", key));
317-
}
302+
CreateIfNotFoundQueryLookupStrategy createIfNotFoundQueryLookupStrategy = new CreateIfNotFoundQueryLookupStrategy(publisher, callbacks, context, converter, dialect, queryMappingConfiguration, operations, createQueryLookupStrategy,
303+
declaredQueryLookupStrategy, delegate);
304+
305+
Key keyToUse = key != null ? key : Key.CREATE_IF_NOT_FOUND;
306+
307+
LOG.debug(String.format("Using the queryLookupStrategy %s", keyToUse));
308+
309+
return switch (keyToUse) {
310+
case CREATE -> createQueryLookupStrategy;
311+
case USE_DECLARED_QUERY -> declaredQueryLookupStrategy;
312+
case CREATE_IF_NOT_FOUND -> createIfNotFoundQueryLookupStrategy;
313+
};
318314
}
319315

320316
JdbcConverter getConverter() {

0 commit comments

Comments
 (0)