Apply "instanceof pattern matching" in AbstractRoutingDataSource
Closes gh-28011
This commit is contained in:
parent
9a0f691e86
commit
1e0e477833
|
@ -153,11 +153,11 @@ public abstract class AbstractRoutingDataSource extends AbstractDataSource imple
|
||||||
* @throws IllegalArgumentException in case of an unsupported value type
|
* @throws IllegalArgumentException in case of an unsupported value type
|
||||||
*/
|
*/
|
||||||
protected DataSource resolveSpecifiedDataSource(Object dataSource) throws IllegalArgumentException {
|
protected DataSource resolveSpecifiedDataSource(Object dataSource) throws IllegalArgumentException {
|
||||||
if (dataSource instanceof DataSource) {
|
if (dataSource instanceof DataSource result) {
|
||||||
return (DataSource) dataSource;
|
return result;
|
||||||
}
|
}
|
||||||
else if (dataSource instanceof String) {
|
else if (dataSource instanceof String name) {
|
||||||
return this.dataSourceLookup.getDataSource((String) dataSource);
|
return this.dataSourceLookup.getDataSource(name);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
|
Loading…
Reference in New Issue