Use new Java features (switch expressions, text blocks, new JDK methods)
Closes gh-29747
This commit is contained in:
committed by
Sam Brannen
parent
48abd493fe
commit
afb8a0d1b1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -107,21 +107,19 @@ class InfrastructureProxyTransactionalSqlScriptsTests extends AbstractTransactio
|
||||
|
||||
@Override
|
||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||
switch (method.getName()) {
|
||||
case "equals":
|
||||
return (proxy == args[0]);
|
||||
case "hashCode":
|
||||
return System.identityHashCode(proxy);
|
||||
case "getWrappedObject":
|
||||
return this.dataSource;
|
||||
default:
|
||||
return switch (method.getName()) {
|
||||
case "equals" -> (proxy == args[0]);
|
||||
case "hashCode" -> System.identityHashCode(proxy);
|
||||
case "getWrappedObject" -> this.dataSource;
|
||||
default -> {
|
||||
try {
|
||||
return method.invoke(this.dataSource, args);
|
||||
yield method.invoke(this.dataSource, args);
|
||||
}
|
||||
catch (InvocationTargetException ex) {
|
||||
throw ex.getTargetException();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user