From f91b255bda853a6ff6da14723cfae1e0afb21d2f Mon Sep 17 00:00:00 2001 From: Janne Valkealahti Date: Sun, 8 Jan 2023 13:38:33 +0000 Subject: [PATCH] Create BuilderSupplier interface - Fixes #607 --- .../boot/CommandCatalogAutoConfiguration.java | 6 +++--- .../shell/boot/StandardAPIAutoConfiguration.java | 6 ++---- .../shell/command/CommandRegistration.java | 10 +++++++++- .../using-shell-commands-programmaticmodel.adoc | 2 +- .../docs/CommandRegistrationBeanSnippets.java | 6 ++---- .../shell/samples/e2e/ArityCommands.java | 6 ++---- .../shell/samples/e2e/DefaultValueCommands.java | 12 +++++------- .../shell/samples/e2e/ErrorHandlingCommands.java | 5 ++--- .../shell/samples/e2e/ExitCodeCommands.java | 6 ++---- .../shell/samples/e2e/HelpOptionCommands.java | 6 ++---- .../shell/samples/e2e/HiddenCommands.java | 6 ++---- .../e2e/InteractiveCompletionCommands.java | 5 ++--- .../shell/samples/e2e/OptionTypeCommands.java | 15 +++++++-------- .../shell/samples/e2e/OptionalValueCommands.java | 4 +--- .../shell/samples/e2e/RequiredValueCommands.java | 6 ++---- .../samples/e2e/UnrecognisedOptionCommands.java | 6 ++---- .../shell/samples/e2e/ValidatedValueCommands.java | 6 ++---- .../shell/samples/e2e/WriteCommands.java | 8 +++----- .../standard/StandardMethodTargetRegistrar.java | 6 +++--- .../StandardMethodTargetRegistrarTests.java | 5 ++--- 20 files changed, 56 insertions(+), 76 deletions(-) diff --git a/spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/CommandCatalogAutoConfiguration.java b/spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/CommandCatalogAutoConfiguration.java index 0deb0346..bc1d4edc 100644 --- a/spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/CommandCatalogAutoConfiguration.java +++ b/spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/CommandCatalogAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2022 the original author or authors. + * Copyright 2021-2023 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. @@ -16,7 +16,6 @@ package org.springframework.shell.boot; import java.util.List; -import java.util.function.Supplier; import java.util.stream.Collectors; import org.springframework.beans.factory.ObjectProvider; @@ -29,6 +28,7 @@ import org.springframework.shell.boot.SpringShellProperties.Help; import org.springframework.shell.command.CommandCatalog; import org.springframework.shell.command.CommandCatalogCustomizer; import org.springframework.shell.command.CommandRegistration; +import org.springframework.shell.command.CommandRegistration.BuilderSupplier; import org.springframework.shell.command.CommandResolver; @AutoConfiguration @@ -76,7 +76,7 @@ public class CommandCatalogAutoConfiguration { @Bean @ConditionalOnMissingBean - public Supplier commandRegistrationBuilderSupplier( + public BuilderSupplier commandRegistrationBuilderSupplier( ObjectProvider customizerProvider) { return () -> { CommandRegistration.Builder builder = CommandRegistration.builder(); diff --git a/spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/StandardAPIAutoConfiguration.java b/spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/StandardAPIAutoConfiguration.java index 841c1005..c015011d 100644 --- a/spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/StandardAPIAutoConfiguration.java +++ b/spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/StandardAPIAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2022 the original author or authors. + * Copyright 2017-2023 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. @@ -16,8 +16,6 @@ package org.springframework.shell.boot; -import java.util.function.Supplier; - import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; @@ -55,7 +53,7 @@ public class StandardAPIAutoConfiguration { @Bean public MethodTargetRegistrar standardMethodTargetResolver(ApplicationContext applicationContext, - Supplier builder) { + CommandRegistration.BuilderSupplier builder) { return new StandardMethodTargetRegistrar(applicationContext, builder); } } diff --git a/spring-shell-core/src/main/java/org/springframework/shell/command/CommandRegistration.java b/spring-shell-core/src/main/java/org/springframework/shell/command/CommandRegistration.java index 7f2f64b2..74a01d6d 100644 --- a/spring-shell-core/src/main/java/org/springframework/shell/command/CommandRegistration.java +++ b/spring-shell-core/src/main/java/org/springframework/shell/command/CommandRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 the original author or authors. + * Copyright 2022-2023 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. @@ -137,6 +137,14 @@ public interface CommandRegistration { return new DefaultBuilder(); } + /** + * Interface used to supply instance of a {@link Builder}. Meant to be a single + * point access to centrally configured builder in an application context. + */ + @FunctionalInterface + public interface BuilderSupplier extends Supplier { + } + /** * Spec defining an option. */ diff --git a/spring-shell-docs/src/main/asciidoc/using-shell-commands-programmaticmodel.adoc b/spring-shell-docs/src/main/asciidoc/using-shell-commands-programmaticmodel.adoc index f2a0b0cd..97f90a7b 100644 --- a/spring-shell-docs/src/main/asciidoc/using-shell-commands-programmaticmodel.adoc +++ b/spring-shell-docs/src/main/asciidoc/using-shell-commands-programmaticmodel.adoc @@ -12,7 +12,7 @@ include::{snippets}/CommandRegistrationBeanSnippets.java[tag=plain] ==== If all your commands have something in common, an instance of -a _Supplier_ is created which can +a _CommandRegistration.BuilderSupplier_ is created which can be autowired. Default implementation of this supplier returns a new builder so you don't need to worry about its internal state. diff --git a/spring-shell-docs/src/test/java/org/springframework/shell/docs/CommandRegistrationBeanSnippets.java b/spring-shell-docs/src/test/java/org/springframework/shell/docs/CommandRegistrationBeanSnippets.java index c8722e50..63770f3b 100644 --- a/spring-shell-docs/src/test/java/org/springframework/shell/docs/CommandRegistrationBeanSnippets.java +++ b/spring-shell-docs/src/test/java/org/springframework/shell/docs/CommandRegistrationBeanSnippets.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 the original author or authors. + * Copyright 2022-2023 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. @@ -15,8 +15,6 @@ */ package org.springframework.shell.docs; -import java.util.function.Supplier; - import org.springframework.context.annotation.Bean; import org.springframework.shell.boot.CommandRegistrationCustomizer; import org.springframework.shell.command.CommandRegistration; @@ -37,7 +35,7 @@ public class CommandRegistrationBeanSnippets { class Dump2 { // tag::fromsupplier[] @Bean - CommandRegistration commandRegistration(Supplier builder) { + CommandRegistration commandRegistration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command("mycommand") .build(); diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/ArityCommands.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/ArityCommands.java index 50407fa3..e4a543c8 100644 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/ArityCommands.java +++ b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/ArityCommands.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 the original author or authors. + * Copyright 2022-2023 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. @@ -15,8 +15,6 @@ */ package org.springframework.shell.samples.e2e; -import java.util.function.Supplier; - import org.springframework.context.annotation.Bean; import org.springframework.shell.command.CommandRegistration; import org.springframework.shell.command.CommandRegistration.OptionArity; @@ -40,7 +38,7 @@ public class ArityCommands extends BaseE2ECommands { } @Bean - public CommandRegistration testBooleanArity1DefaultTrueRegistration(Supplier builder) { + public CommandRegistration testBooleanArity1DefaultTrueRegistration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "boolean-arity1-default-true") .group(GROUP) diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/DefaultValueCommands.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/DefaultValueCommands.java index 9b26a780..cb6c6910 100644 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/DefaultValueCommands.java +++ b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/DefaultValueCommands.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 the original author or authors. + * Copyright 2022-2023 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. @@ -15,8 +15,6 @@ */ package org.springframework.shell.samples.e2e; -import java.util.function.Supplier; - import org.springframework.context.annotation.Bean; import org.springframework.shell.command.CommandRegistration; import org.springframework.shell.standard.ShellComponent; @@ -39,7 +37,7 @@ public class DefaultValueCommands extends BaseE2ECommands { } @Bean - public CommandRegistration testDefaultValueRegistration(Supplier builder) { + public CommandRegistration testDefaultValueRegistration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "default-value") .group(GROUP) @@ -64,7 +62,7 @@ public class DefaultValueCommands extends BaseE2ECommands { } @Bean - public CommandRegistration testDefaultValueBoolean1Registration(Supplier builder) { + public CommandRegistration testDefaultValueBoolean1Registration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "default-value-boolean1") .group(GROUP) @@ -90,7 +88,7 @@ public class DefaultValueCommands extends BaseE2ECommands { } @Bean - public CommandRegistration testDefaultValueBoolean2Registration(Supplier builder) { + public CommandRegistration testDefaultValueBoolean2Registration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "default-value-boolean2") .group(GROUP) @@ -116,7 +114,7 @@ public class DefaultValueCommands extends BaseE2ECommands { } @Bean - public CommandRegistration testDefaultValueBoolean3Registration(Supplier builder) { + public CommandRegistration testDefaultValueBoolean3Registration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "default-value-boolean3") .group(GROUP) diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/ErrorHandlingCommands.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/ErrorHandlingCommands.java index 29fd4eae..cc050c83 100644 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/ErrorHandlingCommands.java +++ b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/ErrorHandlingCommands.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 the original author or authors. + * Copyright 2022-2023 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. @@ -17,7 +17,6 @@ package org.springframework.shell.samples.e2e; import java.io.IOException; import java.io.PrintWriter; -import java.util.function.Supplier; import org.jline.terminal.Terminal; @@ -87,7 +86,7 @@ public class ErrorHandlingCommands extends BaseE2ECommands { } @Bean - CommandRegistration testErrorHandlingRegistration(Supplier builder) { + CommandRegistration testErrorHandlingRegistration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "error-handling") .group(GROUP) diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/ExitCodeCommands.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/ExitCodeCommands.java index 230776ba..9afb3794 100644 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/ExitCodeCommands.java +++ b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/ExitCodeCommands.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 the original author or authors. + * Copyright 2022-2023 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. @@ -15,8 +15,6 @@ */ package org.springframework.shell.samples.e2e; -import java.util.function.Supplier; - import org.springframework.context.annotation.Bean; import org.springframework.shell.command.CommandRegistration; import org.springframework.shell.standard.ShellComponent; @@ -30,7 +28,7 @@ import org.springframework.shell.standard.ShellComponent; public class ExitCodeCommands extends BaseE2ECommands { @Bean - public CommandRegistration testExitCodeRegistration(Supplier builder) { + public CommandRegistration testExitCodeRegistration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "exit-code") .group(GROUP) diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/HelpOptionCommands.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/HelpOptionCommands.java index 5bdea5fc..98da846f 100644 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/HelpOptionCommands.java +++ b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/HelpOptionCommands.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 the original author or authors. + * Copyright 2022-2023 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. @@ -15,8 +15,6 @@ */ package org.springframework.shell.samples.e2e; -import java.util.function.Supplier; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.shell.command.CommandRegistration; @@ -28,7 +26,7 @@ import org.springframework.shell.standard.ShellOption; public class HelpOptionCommands extends BaseE2ECommands { @Autowired - Supplier builder; + CommandRegistration.BuilderSupplier builder; @ShellMethod(key = LEGACY_ANNO + "help-option-default", group = GROUP) public String testHelpOptionDefault( diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/HiddenCommands.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/HiddenCommands.java index 892d90af..d7bf164d 100644 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/HiddenCommands.java +++ b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/HiddenCommands.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 the original author or authors. + * Copyright 2022-2023 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. @@ -15,8 +15,6 @@ */ package org.springframework.shell.samples.e2e; -import java.util.function.Supplier; - import org.springframework.context.annotation.Bean; import org.springframework.shell.command.CommandRegistration; import org.springframework.shell.standard.ShellComponent; @@ -25,7 +23,7 @@ import org.springframework.shell.standard.ShellComponent; public class HiddenCommands extends BaseE2ECommands { @Bean - public CommandRegistration testHidden1Registration(Supplier builder) { + public CommandRegistration testHidden1Registration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "hidden-1") .group(GROUP) diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/InteractiveCompletionCommands.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/InteractiveCompletionCommands.java index 757a8ba1..3139fb06 100644 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/InteractiveCompletionCommands.java +++ b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/InteractiveCompletionCommands.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 the original author or authors. + * Copyright 2022-2023 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. @@ -17,7 +17,6 @@ package org.springframework.shell.samples.e2e; import java.util.Arrays; import java.util.List; -import java.util.function.Supplier; import java.util.stream.Collectors; import org.springframework.context.annotation.Bean; @@ -41,7 +40,7 @@ public class InteractiveCompletionCommands extends BaseE2ECommands { } @Bean - CommandRegistration testInteractiveCompletion1Registration(Supplier builder) { + CommandRegistration testInteractiveCompletion1Registration(CommandRegistration.BuilderSupplier builder) { Test1ValuesProvider test1ValuesProvider = new Test1ValuesProvider(); Test2ValuesProvider test2ValuesProvider = new Test2ValuesProvider(); return builder.get() diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/OptionTypeCommands.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/OptionTypeCommands.java index ac87cc8a..e0c6a4d9 100644 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/OptionTypeCommands.java +++ b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/OptionTypeCommands.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 the original author or authors. + * Copyright 2022-2023 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. @@ -16,7 +16,6 @@ package org.springframework.shell.samples.e2e; import java.io.PrintWriter; -import java.util.function.Supplier; import org.springframework.context.annotation.Bean; import org.springframework.shell.command.CommandRegistration; @@ -33,7 +32,7 @@ import org.springframework.shell.standard.ShellOption; public class OptionTypeCommands extends BaseE2ECommands { @Bean - public CommandRegistration testOptionTypeRegistration(Supplier builder) { + public CommandRegistration testOptionTypeRegistration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "option-type") .group(GROUP) @@ -77,7 +76,7 @@ public class OptionTypeCommands extends BaseE2ECommands { } @Bean - public CommandRegistration optionTypeStringRegistration(Supplier builder) { + public CommandRegistration optionTypeStringRegistration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "option-type-string") .group(GROUP) @@ -113,7 +112,7 @@ public class OptionTypeCommands extends BaseE2ECommands { } @Bean - public CommandRegistration optionTypeBooleanRegistration(Supplier builder) { + public CommandRegistration optionTypeBooleanRegistration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "option-type-boolean") .group(GROUP) @@ -173,7 +172,7 @@ public class OptionTypeCommands extends BaseE2ECommands { } @Bean - public CommandRegistration optionTypeIntegerRegistration(Supplier builder) { + public CommandRegistration optionTypeIntegerRegistration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "option-type-integer") .group(GROUP) @@ -213,7 +212,7 @@ public class OptionTypeCommands extends BaseE2ECommands { } @Bean - public CommandRegistration optionTypeEnumRegistration(Supplier builder) { + public CommandRegistration optionTypeEnumRegistration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "option-type-enum") .group(GROUP) @@ -236,7 +235,7 @@ public class OptionTypeCommands extends BaseE2ECommands { // @Bean - public CommandRegistration optionTypeVoidRegistration(Supplier builder) { + public CommandRegistration optionTypeVoidRegistration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "option-type-void") .group(GROUP) diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/OptionalValueCommands.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/OptionalValueCommands.java index c2792eff..1f48e4cd 100644 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/OptionalValueCommands.java +++ b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/OptionalValueCommands.java @@ -15,8 +15,6 @@ */ package org.springframework.shell.samples.e2e; -import java.util.function.Supplier; - import org.springframework.context.annotation.Bean; import org.springframework.shell.command.CommandRegistration; import org.springframework.shell.standard.ShellComponent; @@ -39,7 +37,7 @@ public class OptionalValueCommands extends BaseE2ECommands { } @Bean - public CommandRegistration testOptionalValueRegistration(Supplier builder) { + public CommandRegistration testOptionalValueRegistration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "optional-value") .group(GROUP) diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/RequiredValueCommands.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/RequiredValueCommands.java index f06014f3..cf0b3c80 100644 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/RequiredValueCommands.java +++ b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/RequiredValueCommands.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 the original author or authors. + * Copyright 2022-2023 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. @@ -15,8 +15,6 @@ */ package org.springframework.shell.samples.e2e; -import java.util.function.Supplier; - import org.springframework.context.annotation.Bean; import org.springframework.shell.command.CommandRegistration; import org.springframework.shell.standard.ShellComponent; @@ -39,7 +37,7 @@ public class RequiredValueCommands extends BaseE2ECommands { } @Bean - public CommandRegistration testRequiredValueRegistration(Supplier builder) { + public CommandRegistration testRequiredValueRegistration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "required-value") .group(GROUP) diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/UnrecognisedOptionCommands.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/UnrecognisedOptionCommands.java index fe7dd690..a7ab0b8f 100644 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/UnrecognisedOptionCommands.java +++ b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/UnrecognisedOptionCommands.java @@ -15,8 +15,6 @@ */ package org.springframework.shell.samples.e2e; -import java.util.function.Supplier; - import org.springframework.context.annotation.Bean; import org.springframework.shell.command.CommandRegistration; import org.springframework.shell.standard.ShellComponent; @@ -33,7 +31,7 @@ public class UnrecognisedOptionCommands extends BaseE2ECommands { } @Bean - public CommandRegistration testUnrecognisedOptionNoOtherRegistration(Supplier builder) { + public CommandRegistration testUnrecognisedOptionNoOtherRegistration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "unrecognised-option-noother") .group(GROUP) @@ -53,7 +51,7 @@ public class UnrecognisedOptionCommands extends BaseE2ECommands { } @Bean - public CommandRegistration testUnrecognisedOptionWithRequiredRegistration(Supplier builder) { + public CommandRegistration testUnrecognisedOptionWithRequiredRegistration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "unrecognised-option-withrequired") .group(GROUP) diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/ValidatedValueCommands.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/ValidatedValueCommands.java index a068c916..cb0ad878 100644 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/ValidatedValueCommands.java +++ b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/ValidatedValueCommands.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 the original author or authors. + * Copyright 2022-2023 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. @@ -15,8 +15,6 @@ */ package org.springframework.shell.samples.e2e; -import java.util.function.Supplier; - import jakarta.validation.constraints.Min; import org.springframework.context.annotation.Bean; @@ -42,7 +40,7 @@ public class ValidatedValueCommands extends BaseE2ECommands { } @Bean - public CommandRegistration testValidatedValueRegistration(Supplier builder) { + public CommandRegistration testValidatedValueRegistration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "validated-value") .group(GROUP) diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/WriteCommands.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/WriteCommands.java index eaa8f39b..2bbd1965 100644 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/WriteCommands.java +++ b/spring-shell-samples/src/main/java/org/springframework/shell/samples/e2e/WriteCommands.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 the original author or authors. + * Copyright 2022-2023 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. @@ -15,8 +15,6 @@ */ package org.springframework.shell.samples.e2e; -import java.util.function.Supplier; - import org.jline.terminal.Terminal; import org.springframework.beans.factory.annotation.Autowired; @@ -32,7 +30,7 @@ public class WriteCommands extends BaseE2ECommands { Terminal terminal; @Bean - public CommandRegistration writeTerminalWriterRegistration(Supplier builder) { + public CommandRegistration writeTerminalWriterRegistration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "write-terminalwriter") .group(GROUP) @@ -52,7 +50,7 @@ public class WriteCommands extends BaseE2ECommands { } @Bean - public CommandRegistration writeSystemOutRegistration(Supplier builder) { + public CommandRegistration writeSystemOutRegistration(CommandRegistration.BuilderSupplier builder) { return builder.get() .command(REG, "write-terminalwriter") .group(GROUP) diff --git a/spring-shell-standard/src/main/java/org/springframework/shell/standard/StandardMethodTargetRegistrar.java b/spring-shell-standard/src/main/java/org/springframework/shell/standard/StandardMethodTargetRegistrar.java index 6d34fb55..c19d4018 100644 --- a/spring-shell-standard/src/main/java/org/springframework/shell/standard/StandardMethodTargetRegistrar.java +++ b/spring-shell-standard/src/main/java/org/springframework/shell/standard/StandardMethodTargetRegistrar.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2022 the original author or authors. + * Copyright 2015-2023 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. @@ -68,10 +68,10 @@ public class StandardMethodTargetRegistrar implements MethodTargetRegistrar { private final Logger log = LoggerFactory.getLogger(StandardMethodTargetRegistrar.class); private ApplicationContext applicationContext; - private Supplier commandRegistrationBuilderSupplier; + private CommandRegistration.BuilderSupplier commandRegistrationBuilderSupplier; public StandardMethodTargetRegistrar(ApplicationContext applicationContext, - Supplier commandRegistrationBuilderSupplier) { + CommandRegistration.BuilderSupplier commandRegistrationBuilderSupplier) { this.applicationContext = applicationContext; this.commandRegistrationBuilderSupplier = commandRegistrationBuilderSupplier; } diff --git a/spring-shell-standard/src/test/java/org/springframework/shell/standard/StandardMethodTargetRegistrarTests.java b/spring-shell-standard/src/test/java/org/springframework/shell/standard/StandardMethodTargetRegistrarTests.java index 211ac9f4..fe7885e6 100644 --- a/spring-shell-standard/src/test/java/org/springframework/shell/standard/StandardMethodTargetRegistrarTests.java +++ b/spring-shell-standard/src/test/java/org/springframework/shell/standard/StandardMethodTargetRegistrarTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2022 the original author or authors. + * Copyright 2017-2023 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. @@ -17,7 +17,6 @@ package org.springframework.shell.standard; import java.util.Map; -import java.util.function.Supplier; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -47,7 +46,7 @@ public class StandardMethodTargetRegistrarTests { private AnnotationConfigApplicationContext applicationContext; private CommandCatalog catalog; private DefaultShellContext shellContext; - private Supplier builder = () -> CommandRegistration.builder(); + private CommandRegistration.BuilderSupplier builder = () -> CommandRegistration.builder(); @BeforeEach public void setup() {