Class PromptBuilder<TOption>
- java.lang.Object
-
- com.github.rvesse.airline.builder.AbstractBuilder<Prompt<TOption>>
-
- com.github.rvesse.airline.prompts.builders.PromptBuilder<TOption>
-
- Type Parameters:
TOption
- Option
public class PromptBuilder<TOption> extends AbstractBuilder<Prompt<TOption>>
A prompt builder is used to define a prompt in a Fluent API style
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
allowsNumericOptionSelection
private TypeConverter
converter
private PromptFormatBuilder<TOption>
formatBuilder
private PromptFormatter
formatter
private java.lang.String
message
private PromptOptionMatcher<TOption>
optionMatcher
private java.util.List<TOption>
options
private PromptProvider
provider
private long
timeout
private java.util.concurrent.TimeUnit
timeoutUnit
-
Constructor Summary
Constructors Constructor Description PromptBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Prompt<TOption>
build()
Builds the typePromptBuilder<TOption>
clearOptions()
Clears all previously specified optionsPromptBuilder<TOption>
withDefaultFormatter()
Specifies that the default formatter should be used, this is the list formatterPromptBuilder<TOption>
withDefaultOptionMatcher()
Specifies that the default option matcher be usedPromptBuilder<TOption>
withDefaultPromptProvider()
Specifies that the default prompt provider should be usedPromptBuilder<TOption>
withDefaultTypeConverter()
Specifies that the default type converter be usedPromptFormatBuilder<TOption>
withFormatBuilder()
Switches to a child builder for the prompt formatPromptBuilder<TOption>
withFormatBuilder(PromptFormatBuilder<TOption> formatBuilder)
Specifies the prompt formatter builder to usePromptBuilder<TOption>
withFormatter(PromptFormatter formatter)
Specifies the prompt formatter to useListFormatBuilder<TOption>
withListFormatBuilder()
Switches to a child builder for the list formatterPromptBuilder<TOption>
withListFormatter()
Specifies that a list formatter should be usedPromptBuilder<TOption>
withNumericOptionSelection()
Enables numeric option selectionPromptBuilder<TOption>
withOption(TOption option)
Specifies an option for the promptPromptBuilder<TOption>
withOptionMatcher(PromptOptionMatcher<TOption> matcher)
Specifies the option matcher to usePromptBuilder<TOption>
withOptions(TOption... options)
Specifies one/more options for the promptPromptBuilder<TOption>
withoutNumericOptionSelection()
Disables numeric option selectionPromptBuilder<TOption>
withoutTimeout()
Specifies that no timeout should be usedPromptBuilder<TOption>
withPromptMessage(java.lang.String message)
Specifies the prompt message to displayPromptBuilder<TOption>
withPromptProvider(PromptProvider provider)
Specifies that the given prompt provider should be usedPromptBuilder<TOption>
withQuestionFormatter()
Specifies that a question formatter should be usedPromptBuilder<TOption>
withTimeout(long timeout)
Specifies the timeoutPromptBuilder<TOption>
withTimeout(long timeout, java.util.concurrent.TimeUnit unit)
Specifies the timeoutPromptBuilder<TOption>
withTimeoutUnit(java.util.concurrent.TimeUnit unit)
Specifies the time unit used to apply timeouts to promptsPromptBuilder<TOption>
withTypeConverter(TypeConverter converter)
Specifies the type converter to use-
Methods inherited from class com.github.rvesse.airline.builder.AbstractBuilder
checkNotBlank, checkNotEmpty, checkNotNull
-
-
-
-
Field Detail
-
provider
private PromptProvider provider
-
formatter
private PromptFormatter formatter
-
formatBuilder
private PromptFormatBuilder<TOption> formatBuilder
-
timeout
private long timeout
-
timeoutUnit
private java.util.concurrent.TimeUnit timeoutUnit
-
allowsNumericOptionSelection
private boolean allowsNumericOptionSelection
-
options
private java.util.List<TOption> options
-
optionMatcher
private PromptOptionMatcher<TOption> optionMatcher
-
message
private java.lang.String message
-
converter
private TypeConverter converter
-
-
Method Detail
-
withDefaultPromptProvider
public PromptBuilder<TOption> withDefaultPromptProvider()
Specifies that the default prompt provider should be used- Returns:
- Builder
-
withPromptProvider
public PromptBuilder<TOption> withPromptProvider(PromptProvider provider)
Specifies that the given prompt provider should be used- Parameters:
provider
- Prompt provider- Returns:
- Builder
-
withTimeoutUnit
public PromptBuilder<TOption> withTimeoutUnit(java.util.concurrent.TimeUnit unit)
Specifies the time unit used to apply timeouts to prompts- Parameters:
unit
- Time Unit- Returns:
- Builder
-
withTimeout
public PromptBuilder<TOption> withTimeout(long timeout)
Specifies the timeout- Parameters:
timeout
- Timeout- Returns:
- Builder
-
withTimeout
public PromptBuilder<TOption> withTimeout(long timeout, java.util.concurrent.TimeUnit unit)
Specifies the timeout- Parameters:
timeout
- Timeoutunit
- Time Unit- Returns:
- Builder
-
withoutTimeout
public PromptBuilder<TOption> withoutTimeout()
Specifies that no timeout should be used- Returns:
- Builder
-
withOptions
public PromptBuilder<TOption> withOptions(TOption... options)
Specifies one/more options for the prompt- Parameters:
options
- Options- Returns:
- Builder
-
withOption
public PromptBuilder<TOption> withOption(TOption option)
Specifies an option for the prompt- Parameters:
option
- Option- Returns:
- Builder
-
clearOptions
public PromptBuilder<TOption> clearOptions()
Clears all previously specified options- Returns:
- Builder
-
withNumericOptionSelection
public PromptBuilder<TOption> withNumericOptionSelection()
Enables numeric option selection- Returns:
- Builder
-
withoutNumericOptionSelection
public PromptBuilder<TOption> withoutNumericOptionSelection()
Disables numeric option selection- Returns:
- Builder
-
withOptionMatcher
public PromptBuilder<TOption> withOptionMatcher(PromptOptionMatcher<TOption> matcher)
Specifies the option matcher to use- Parameters:
matcher
- Option matcher- Returns:
- Builder
-
withDefaultOptionMatcher
public PromptBuilder<TOption> withDefaultOptionMatcher()
Specifies that the default option matcher be used- Returns:
- Builder
-
withPromptMessage
public PromptBuilder<TOption> withPromptMessage(java.lang.String message)
Specifies the prompt message to display- Parameters:
message
- Message- Returns:
- Builder
-
withFormatter
public PromptBuilder<TOption> withFormatter(PromptFormatter formatter)
Specifies the prompt formatter to use- Parameters:
formatter
- Formatter- Returns:
- Builder
-
withFormatBuilder
public PromptBuilder<TOption> withFormatBuilder(PromptFormatBuilder<TOption> formatBuilder)
Specifies the prompt formatter builder to use- Parameters:
formatBuilder
- Format Builder- Returns:
- Builder
-
withFormatBuilder
public PromptFormatBuilder<TOption> withFormatBuilder()
Switches to a child builder for the prompt format- Returns:
- Prompt Format Builder
-
withListFormatBuilder
public ListFormatBuilder<TOption> withListFormatBuilder()
Switches to a child builder for the list formatter- Returns:
- List Format Builder
-
withListFormatter
public PromptBuilder<TOption> withListFormatter()
Specifies that a list formatter should be used- Returns:
- Builder
-
withQuestionFormatter
public PromptBuilder<TOption> withQuestionFormatter()
Specifies that a question formatter should be used- Returns:
- Builder
-
withDefaultFormatter
public PromptBuilder<TOption> withDefaultFormatter()
Specifies that the default formatter should be used, this is the list formatter- Returns:
- Builder
-
withTypeConverter
public PromptBuilder<TOption> withTypeConverter(TypeConverter converter)
Specifies the type converter to use- Parameters:
converter
- Type Converter- Returns:
- Builder
-
withDefaultTypeConverter
public PromptBuilder<TOption> withDefaultTypeConverter()
Specifies that the default type converter be used- Returns:
-
build
public Prompt<TOption> build()
Description copied from class:AbstractBuilder
Builds the type- Specified by:
build
in classAbstractBuilder<Prompt<TOption>>
- Returns:
- Type instance
-
-