|
30 | 30 | import io.bootique.jdbc.managed.ManagedDataSourceFactory; |
31 | 31 |
|
32 | 32 | import jakarta.inject.Inject; |
| 33 | + |
33 | 34 | import java.util.ArrayList; |
34 | 35 | import java.util.HashSet; |
35 | 36 | import java.util.List; |
@@ -98,18 +99,19 @@ private String defaultJsonTypeName() { |
98 | 99 | // We can guess the default only if there's a single implementor. |
99 | 100 | Set<Class<? extends ManagedDataSourceFactory>> types = leafFactories(allFactories); |
100 | 101 |
|
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 -> { |
108 | 108 | 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 | + }; |
113 | 115 | } |
114 | 116 |
|
115 | 117 | static String jsonTypeName(Class<?> type) { |
|
0 commit comments