Skip to content

Commit 2302edf

Browse files
committed
going crazy with Java 21 syntax
1 parent f951060 commit 2302edf

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

bootique-jdbc/src/main/java/io/bootique/jdbc/ManagedDataSourceTypeDetector.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import io.bootique.jdbc.managed.ManagedDataSourceFactory;
3131

3232
import jakarta.inject.Inject;
33+
3334
import java.util.ArrayList;
3435
import java.util.HashSet;
3536
import java.util.List;
@@ -98,18 +99,19 @@ private String defaultJsonTypeName() {
9899
// We can guess the default only if there's a single implementor.
99100
Set<Class<? extends ManagedDataSourceFactory>> types = leafFactories(allFactories);
100101

101-
switch (types.size()) {
102-
case 0:
103-
throw new BootiqueException(1, "No concrete 'bootique-jdbc' implementation found. " +
104-
"You will need to add one (such as 'bootique-jdbc-hikaricp', etc.) as an application dependency.");
105-
case 1:
106-
return jsonTypeName(types.iterator().next());
107-
default:
102+
return switch (types.size()) {
103+
case 0 -> throw new BootiqueException(1, """
104+
No concrete 'bootique-jdbc' implementation found. You will need to add one \
105+
(such as 'bootique-jdbc-hikaricp', etc.) as an application dependency.""");
106+
case 1 -> jsonTypeName(types.iterator().next());
107+
default -> {
108108
List<String> typeNames = types.stream().map(t -> jsonTypeName(t)).collect(Collectors.toList());
109-
throw new BootiqueException(1, "More than one 'bootique-jdbc' implementation is found. There's no single default. " +
110-
"As a result, each DataSource configuration must provide an explicit 'type' property. " +
111-
"Supported types: " + typeNames);
112-
}
109+
throw new BootiqueException(1, """
110+
More than one 'bootique-jdbc' implementation is found. There's no single default. \
111+
As a result, each DataSource configuration must provide an explicit 'type' property. \
112+
Supported types: """ + typeNames);
113+
}
114+
};
113115
}
114116

115117
static String jsonTypeName(Class<?> type) {

0 commit comments

Comments
 (0)