Create BuilderSupplier interface

- Fixes #607
This commit is contained in:
Janne Valkealahti
2023-01-08 13:38:33 +00:00
parent 9b4e347633
commit f91b255bda
20 changed files with 56 additions and 76 deletions

View File

@@ -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<CommandRegistration.Builder> builder) {
public CommandRegistration testBooleanArity1DefaultTrueRegistration(CommandRegistration.BuilderSupplier builder) {
return builder.get()
.command(REG, "boolean-arity1-default-true")
.group(GROUP)

View File

@@ -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<CommandRegistration.Builder> 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<CommandRegistration.Builder> 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<CommandRegistration.Builder> 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<CommandRegistration.Builder> builder) {
public CommandRegistration testDefaultValueBoolean3Registration(CommandRegistration.BuilderSupplier builder) {
return builder.get()
.command(REG, "default-value-boolean3")
.group(GROUP)

View File

@@ -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<CommandRegistration.Builder> builder) {
CommandRegistration testErrorHandlingRegistration(CommandRegistration.BuilderSupplier builder) {
return builder.get()
.command(REG, "error-handling")
.group(GROUP)

View File

@@ -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<CommandRegistration.Builder> builder) {
public CommandRegistration testExitCodeRegistration(CommandRegistration.BuilderSupplier builder) {
return builder.get()
.command(REG, "exit-code")
.group(GROUP)

View File

@@ -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<CommandRegistration.Builder> builder;
CommandRegistration.BuilderSupplier builder;
@ShellMethod(key = LEGACY_ANNO + "help-option-default", group = GROUP)
public String testHelpOptionDefault(

View File

@@ -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<CommandRegistration.Builder> builder) {
public CommandRegistration testHidden1Registration(CommandRegistration.BuilderSupplier builder) {
return builder.get()
.command(REG, "hidden-1")
.group(GROUP)

View File

@@ -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<CommandRegistration.Builder> builder) {
CommandRegistration testInteractiveCompletion1Registration(CommandRegistration.BuilderSupplier builder) {
Test1ValuesProvider test1ValuesProvider = new Test1ValuesProvider();
Test2ValuesProvider test2ValuesProvider = new Test2ValuesProvider();
return builder.get()

View File

@@ -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<CommandRegistration.Builder> 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<CommandRegistration.Builder> 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<CommandRegistration.Builder> 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<CommandRegistration.Builder> 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<CommandRegistration.Builder> 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<CommandRegistration.Builder> builder) {
public CommandRegistration optionTypeVoidRegistration(CommandRegistration.BuilderSupplier builder) {
return builder.get()
.command(REG, "option-type-void")
.group(GROUP)

View File

@@ -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<CommandRegistration.Builder> builder) {
public CommandRegistration testOptionalValueRegistration(CommandRegistration.BuilderSupplier builder) {
return builder.get()
.command(REG, "optional-value")
.group(GROUP)

View File

@@ -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<CommandRegistration.Builder> builder) {
public CommandRegistration testRequiredValueRegistration(CommandRegistration.BuilderSupplier builder) {
return builder.get()
.command(REG, "required-value")
.group(GROUP)

View File

@@ -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<CommandRegistration.Builder> 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<CommandRegistration.Builder> builder) {
public CommandRegistration testUnrecognisedOptionWithRequiredRegistration(CommandRegistration.BuilderSupplier builder) {
return builder.get()
.command(REG, "unrecognised-option-withrequired")
.group(GROUP)

View File

@@ -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<CommandRegistration.Builder> builder) {
public CommandRegistration testValidatedValueRegistration(CommandRegistration.BuilderSupplier builder) {
return builder.get()
.command(REG, "validated-value")
.group(GROUP)

View File

@@ -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<CommandRegistration.Builder> 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<CommandRegistration.Builder> builder) {
public CommandRegistration writeSystemOutRegistration(CommandRegistration.BuilderSupplier builder) {
return builder.get()
.command(REG, "write-terminalwriter")
.group(GROUP)