File tree 1 file changed +6
-9
lines changed
src/main/java/org/springframework/data/r2dbc/dialect
1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change 25
25
26
26
import org .springframework .core .io .support .SpringFactoriesLoader ;
27
27
import org .springframework .dao .NonTransientDataAccessException ;
28
+ import org .springframework .data .util .Optionals ;
28
29
import org .springframework .util .LinkedCaseInsensitiveMap ;
29
30
30
31
/**
@@ -55,9 +56,8 @@ public static R2dbcDialect getDialect(ConnectionFactory connectionFactory) {
55
56
56
57
return DETECTORS .stream () //
57
58
.map (it -> it .getDialect (connectionFactory )) //
58
- .filter ( Optional :: isPresent ) //
59
+ .flatMap ( Optionals :: toStream ) //
59
60
.findFirst () //
60
- .flatMap (it -> it ) //
61
61
.orElseThrow (() -> {
62
62
return new NoDialectException (
63
63
String .format ("Cannot determine a dialect for %s using %s. Please provide a Dialect." ,
@@ -127,13 +127,10 @@ public Optional<R2dbcDialect> getDialect(ConnectionFactory connectionFactory) {
127
127
return Optional .of (r2dbcDialect );
128
128
}
129
129
130
- for (String key : BUILTIN .keySet ()) {
131
- if (metadata .getName ().contains (key )) {
132
- return Optional .of (BUILTIN .get (key ));
133
- }
134
- }
135
-
136
- return Optional .empty ();
130
+ return BUILTIN .keySet ().stream () //
131
+ .filter (it -> metadata .getName ().contains (it )) //
132
+ .map (BUILTIN ::get ) //
133
+ .findFirst ();
137
134
}
138
135
}
139
136
}
You can’t perform that action at this time.
0 commit comments