- java.lang.Object
-
- org.jline.prompt.impl.DefaultListBuilder
-
- All Implemented Interfaces:
BaseBuilder<ListBuilder>,ListBuilder
public class DefaultListBuilder extends java.lang.Object implements ListBuilder
Default implementation of ListBuilder. This is now the native implementation that doesn't depend on console-ui.
-
-
Constructor Summary
Constructors Constructor Description DefaultListBuilder(PromptBuilder parent)Create a new DefaultListBuilder with the given parent.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ListBuilderadd()Add the current item to the list.PromptBuilderaddPrompt()Add this prompt to the parent builder and return to the parent.voidaddSeparator(SeparatorItem separatorItem)Add a separator item to the list.ListBuilderdisabled(boolean disabled)Set whether the current item is disabled.ListBuilderdisabledText(java.lang.String disabledText)Set the disabled text for the current item.ListBuilderfilter(java.util.function.Function<java.lang.String,java.lang.String> filter)Set a filter function that modifies the actual returned value.ListBuilderfilterable(boolean filterable)Set whether the list supports inline text filtering.ListBuilderfooter(java.lang.String footer)Set the footer text for the current item.ListBuildermessage(java.lang.String message)Set the message to display to the user.ListBuildername(java.lang.String name)Set the name of this prompt.ListBuildernewItem(java.lang.String id)Create a new item with the given ID.ListSeparatorBuildernewSeparator()Create a new separator with no text.ListSeparatorBuildernewSeparator(java.lang.String text)Create a new separator with the given text.ListBuilderpageSize(int pageSize)Set the page size for pagination.ListBuildershowPageIndicator(boolean showPageIndicator)Set whether to show page indicators.ListBuildertext(java.lang.String text)Set the text for the current item.ListBuildertransformer(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.ListBuilder
add, add, add
-
-
-
-
Constructor Detail
-
DefaultListBuilder
public DefaultListBuilder(PromptBuilder parent)
Create a new DefaultListBuilder with the given parent.- Parameters:
parent- the parent builder
-
-
Method Detail
-
name
public ListBuilder name(java.lang.String name)
Set the name of this prompt.- Specified by:
namein interfaceBaseBuilder<ListBuilder>- Parameters:
name- the name- Returns:
- this builder
-
message
public ListBuilder message(java.lang.String message)
Set the message to display to the user.- Specified by:
messagein interfaceBaseBuilder<ListBuilder>- Parameters:
message- the message- Returns:
- this builder
-
newItem
public ListBuilder newItem(java.lang.String id)
Create a new item with the given ID.- Specified by:
newItemin interfaceListBuilder- Parameters:
id- the ID- Returns:
- this builder
-
text
public ListBuilder text(java.lang.String text)
Set the text for the current item.- Specified by:
textin interfaceListBuilder- Parameters:
text- the text- Returns:
- this builder
-
disabled
public ListBuilder disabled(boolean disabled)
Set whether the current item is disabled.- Specified by:
disabledin interfaceListBuilder- Parameters:
disabled- whether the item is disabled- Returns:
- this builder
-
disabledText
public ListBuilder disabledText(java.lang.String disabledText)
Set the disabled text for the current item.- Specified by:
disabledTextin interfaceListBuilder- Parameters:
disabledText- the disabled text- Returns:
- this builder
-
footer
public ListBuilder footer(java.lang.String footer)
Description copied from interface:ListBuilderSet the footer text for the current item. The footer is shown dimmed below the list while this item is focused. Newlines split it into multiple lines and long lines wrap to the terminal width; the footer pane has a fixed height so the list does not shift between items.- Specified by:
footerin interfaceListBuilder- Parameters:
footer- the footer text, ornull/empty for none- Returns:
- this builder
-
add
public ListBuilder add()
Add the current item to the list.- Specified by:
addin interfaceListBuilder- Returns:
- this builder
-
filterable
public ListBuilder filterable(boolean filterable)
Description copied from interface:ListBuilderSet whether the list supports inline text filtering. When enabled (the default), the user can type characters to filter the displayed items. When disabled, typed characters are ignored.- Specified by:
filterablein interfaceListBuilder- Parameters:
filterable- true to enable filtering, false to disable- Returns:
- this builder
-
pageSize
public ListBuilder pageSize(int pageSize)
Description copied from interface:ListBuilderSet the page size for pagination.- Specified by:
pageSizein interfaceListBuilder- Parameters:
pageSize- the page size, or 0 for no pagination- Returns:
- this builder
-
showPageIndicator
public ListBuilder showPageIndicator(boolean showPageIndicator)
Description copied from interface:ListBuilderSet whether to show page indicators.- Specified by:
showPageIndicatorin interfaceListBuilder- Parameters:
showPageIndicator- true to show page indicators- Returns:
- this builder
-
newSeparator
public ListSeparatorBuilder newSeparator()
Description copied from interface:ListBuilderCreate a new separator with no text.- Specified by:
newSeparatorin interfaceListBuilder- Returns:
- a separator builder
-
newSeparator
public ListSeparatorBuilder newSeparator(java.lang.String text)
Description copied from interface:ListBuilderCreate a new separator with the given text.- Specified by:
newSeparatorin interfaceListBuilder- Parameters:
text- the separator text- Returns:
- a separator builder
-
addSeparator
public void addSeparator(SeparatorItem separatorItem)
Add a separator item to the list.- Parameters:
separatorItem- the separator item to add
-
transformer
public ListBuilder 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<ListBuilder>- Parameters:
transformer- the transformer function- Returns:
- this builder instance for method chaining
-
filter
public ListBuilder 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<ListBuilder>- Parameters:
filter- the filter function- Returns:
- this builder instance for method chaining
-
addPrompt
public PromptBuilder addPrompt()
Add this prompt to the parent builder and return to the parent.- Specified by:
addPromptin interfaceBaseBuilder<ListBuilder>- Returns:
- the parent prompt builder
- See Also:
PromptBuilder.build()
-
-