diff --git a/spring-context/src/main/java/org/springframework/context/aot/AbstractAotProcessor.java b/spring-context/src/main/java/org/springframework/context/aot/AbstractAotProcessor.java index e538de87ab..d51d8af1f2 100644 --- a/spring-context/src/main/java/org/springframework/context/aot/AbstractAotProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/aot/AbstractAotProcessor.java @@ -123,9 +123,11 @@ public abstract class AbstractAotProcessor { /** * Set the output directory for generated sources. * @param sourceOutput the location of generated sources + * @return this settings object for method chaining */ - public void setSourceOutput(Path sourceOutput) { + public Settings setSourceOutput(Path sourceOutput) { this.sourceOutput = sourceOutput; + return this; } /** @@ -139,9 +141,11 @@ public abstract class AbstractAotProcessor { /** * Set the output directory for generated resources. * @param resourceOutput the location of generated resources + * @return this settings object for method chaining */ - public void setResourceOutput(Path resourceOutput) { + public Settings setResourceOutput(Path resourceOutput) { this.resourceOutput = resourceOutput; + return this; } /** @@ -155,9 +159,11 @@ public abstract class AbstractAotProcessor { /** * Set the output directory for generated classes. * @param classOutput the location of generated classes + * @return this settings object for method chaining */ - public void setClassOutput(Path classOutput) { + public Settings setClassOutput(Path classOutput) { this.classOutput = classOutput; + return this; } /** @@ -172,9 +178,11 @@ public abstract class AbstractAotProcessor { * Set the group ID of the application. * @param groupId the group ID of the application, used to locate * {@code native-image.properties} + * @return this settings object for method chaining */ - public void setGroupId(String groupId) { + public Settings setGroupId(String groupId) { this.groupId = groupId; + return this; } /** @@ -189,9 +197,11 @@ public abstract class AbstractAotProcessor { * Set the artifact ID of the application. * @param artifactId the artifact ID of the application, used to locate * {@code native-image.properties} + * @return this settings object for method chaining */ - public void setArtifactId(String artifactId) { + public Settings setArtifactId(String artifactId) { this.artifactId = artifactId; + return this; } /** diff --git a/spring-context/src/test/java/org/springframework/context/aot/ContextAotProcessorTests.java b/spring-context/src/test/java/org/springframework/context/aot/ContextAotProcessorTests.java index f500ac9648..5baeea5bb7 100644 --- a/spring-context/src/test/java/org/springframework/context/aot/ContextAotProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/aot/ContextAotProcessorTests.java @@ -128,13 +128,12 @@ class ContextAotProcessorTests { private static Settings createSettings(Path sourceOutput, Path resourceOutput, Path classOutput, String groupId, String artifactId) { - Settings settings = new Settings(); - settings.setSourceOutput(sourceOutput); - settings.setResourceOutput(resourceOutput); - settings.setClassOutput(classOutput); - settings.setArtifactId(artifactId); - settings.setGroupId(groupId); - return settings; + return new Settings() + .setSourceOutput(sourceOutput) + .setResourceOutput(resourceOutput) + .setClassOutput(classOutput) + .setArtifactId(artifactId) + .setGroupId(groupId); } @Override diff --git a/spring-test/src/test/java/org/springframework/test/context/aot/TestAotProcessorTests.java b/spring-test/src/test/java/org/springframework/test/context/aot/TestAotProcessorTests.java index 4cccdcd3cd..eee73dae06 100644 --- a/spring-test/src/test/java/org/springframework/test/context/aot/TestAotProcessorTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/aot/TestAotProcessorTests.java @@ -109,13 +109,12 @@ class TestAotProcessorTests extends AbstractAotTests { private static Settings createSettings(Path sourceOutput, Path resourceOutput, Path classOutput, String groupId, String artifactId) { - Settings settings = new Settings(); - settings.setSourceOutput(sourceOutput); - settings.setResourceOutput(resourceOutput); - settings.setClassOutput(classOutput); - settings.setArtifactId(artifactId); - settings.setGroupId(groupId); - return settings; + return new Settings() + .setSourceOutput(sourceOutput) + .setResourceOutput(resourceOutput) + .setClassOutput(classOutput) + .setArtifactId(artifactId) + .setGroupId(groupId); } }