- java.lang.Object
-
- org.jline.prompt.impl.DefaultChoiceBuilder
-
- All Implemented Interfaces:
BaseBuilder<ChoiceBuilder>,ChoiceBuilder
public class DefaultChoiceBuilder extends java.lang.Object implements ChoiceBuilder
Default implementation of ChoiceBuilder. This is now the native implementation that doesn't depend on console-ui.
-
-
Constructor Summary
Constructors Constructor Description DefaultChoiceBuilder(PromptBuilder parent)Create a new DefaultChoiceBuilder with the given parent.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChoiceBuilderadd()Add the current choice to the list.PromptBuilderaddPrompt()Add this prompt to the parent builder.ChoiceBuilderdefaultChoice(boolean defaultChoice)Set whether the current choice is the default.ChoiceBuilderfilter(java.util.function.Function<java.lang.String,java.lang.String> filter)Set a filter function that modifies the actual returned value.ChoiceBuilderhelpText(java.lang.String helpText)Set the help text for the current choice.ChoiceBuilderkey(char key)Set the key for the current choice.ChoiceBuildermessage(java.lang.String message)Set the message to display to the user.ChoiceBuildername(java.lang.String name)Set the name of this prompt.ChoiceBuildernewChoice(java.lang.String id)Create a new choice with the given ID.ChoiceBuildertext(java.lang.String text)Set the text for the current choice.ChoiceBuildertransformer(java.util.function.Function<java.lang.String,java.lang.String> transformer)Set a transformer function that modifies how the answer is displayed after submission.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jline.prompt.ChoiceBuilder
add, add, add
-
-
-
-
Constructor Detail
-
DefaultChoiceBuilder
public DefaultChoiceBuilder(PromptBuilder parent)
Create a new DefaultChoiceBuilder with the given parent.- Parameters:
parent- the parent builder
-
-
Method Detail
-
name
public ChoiceBuilder name(java.lang.String name)
Set the name of this prompt.- Specified by:
namein interfaceBaseBuilder<ChoiceBuilder>- Parameters:
name- the name- Returns:
- this builder
-
message
public ChoiceBuilder message(java.lang.String message)
Set the message to display to the user.- Specified by:
messagein interfaceBaseBuilder<ChoiceBuilder>- Parameters:
message- the message- Returns:
- this builder
-
newChoice
public ChoiceBuilder newChoice(java.lang.String id)
Create a new choice with the given ID.- Specified by:
newChoicein interfaceChoiceBuilder- Parameters:
id- the ID- Returns:
- this builder
-
key
public ChoiceBuilder key(char key)
Set the key for the current choice.- Specified by:
keyin interfaceChoiceBuilder- Parameters:
key- the key- Returns:
- this builder
-
text
public ChoiceBuilder text(java.lang.String text)
Set the text for the current choice.- Specified by:
textin interfaceChoiceBuilder- Parameters:
text- the text- Returns:
- this builder
-
helpText
public ChoiceBuilder helpText(java.lang.String helpText)
Set the help text for the current choice.- Specified by:
helpTextin interfaceChoiceBuilder- Parameters:
helpText- the help text- Returns:
- this builder
-
defaultChoice
public ChoiceBuilder defaultChoice(boolean defaultChoice)
Set whether the current choice is the default.- Specified by:
defaultChoicein interfaceChoiceBuilder- Parameters:
defaultChoice- whether the choice is the default- Returns:
- this builder
-
add
public ChoiceBuilder add()
Add the current choice to the list.- Specified by:
addin interfaceChoiceBuilder- Returns:
- this builder
-
transformer
public ChoiceBuilder transformer(java.util.function.Function<java.lang.String,java.lang.String> transformer)
Description copied from interface:BaseBuilderSet a transformer function that modifies how the answer is displayed after submission. This does not change the actual returned value. For example, a password prompt might transform the answer to "***".- Specified by:
transformerin interfaceBaseBuilder<ChoiceBuilder>- Parameters:
transformer- the transformer function- Returns:
- this builder instance for method chaining
-
filter
public ChoiceBuilder filter(java.util.function.Function<java.lang.String,java.lang.String> filter)
Description copied from interface:BaseBuilderSet a filter function that modifies the actual returned value. This changes the value stored in the result map. For example, trimming whitespace or converting to lowercase.- Specified by:
filterin interfaceBaseBuilder<ChoiceBuilder>- Parameters:
filter- the filter function- Returns:
- this builder instance for method chaining
-
addPrompt
public PromptBuilder addPrompt()
Add this prompt to the parent builder.- Specified by:
addPromptin interfaceBaseBuilder<ChoiceBuilder>- Returns:
- the parent
PromptBuilderfor continued prompt configuration - See Also:
PromptBuilder.build()
-
-