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-2018 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.
|
||||
@@ -45,15 +45,13 @@ public class TransactionManagementConfigurationSelector extends AdviceModeImport
|
||||
*/
|
||||
@Override
|
||||
protected String[] selectImports(AdviceMode adviceMode) {
|
||||
switch (adviceMode) {
|
||||
case PROXY:
|
||||
return new String[] {AutoProxyRegistrar.class.getName(),
|
||||
ProxyTransactionManagementConfiguration.class.getName()};
|
||||
case ASPECTJ:
|
||||
return new String[] {determineTransactionAspectClass()};
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return switch (adviceMode) {
|
||||
case PROXY -> new String[]{
|
||||
AutoProxyRegistrar.class.getName(),
|
||||
ProxyTransactionManagementConfiguration.class.getName()
|
||||
};
|
||||
case ASPECTJ -> new String[]{determineTransactionAspectClass()};
|
||||
};
|
||||
}
|
||||
|
||||
private String determineTransactionAspectClass() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -56,12 +56,12 @@ public class TransactionAttributeSourceEditorTests {
|
||||
|
||||
@Test
|
||||
public void matchesSpecific() throws Exception {
|
||||
editor.setAsText(
|
||||
"java.lang.Object.hashCode=PROPAGATION_REQUIRED\n" +
|
||||
"java.lang.Object.equals=PROPAGATION_MANDATORY\n" +
|
||||
"java.lang.Object.*it=PROPAGATION_SUPPORTS\n" +
|
||||
"java.lang.Object.notify=PROPAGATION_SUPPORTS\n" +
|
||||
"java.lang.Object.not*=PROPAGATION_REQUIRED");
|
||||
editor.setAsText("""
|
||||
java.lang.Object.hashCode=PROPAGATION_REQUIRED
|
||||
java.lang.Object.equals=PROPAGATION_MANDATORY
|
||||
java.lang.Object.*it=PROPAGATION_SUPPORTS
|
||||
java.lang.Object.notify=PROPAGATION_SUPPORTS
|
||||
java.lang.Object.not*=PROPAGATION_REQUIRED""");
|
||||
TransactionAttributeSource tas = (TransactionAttributeSource) editor.getValue();
|
||||
|
||||
checkTransactionProperties(tas, Object.class.getMethod("hashCode"),
|
||||
|
||||
Reference in New Issue
Block a user