Class AbstractSelectorComponent<T,C extends AbstractSelectorComponent.SelectorComponentContext<T,I,C>,I extends Nameable & Matchable & Enableable & Selectable & Itemable<T>>
java.lang.Object
org.springframework.shell.component.support.AbstractComponent<C>
org.springframework.shell.component.support.AbstractSelectorComponent<T,C,I>
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.context.ResourceLoaderAware
- Direct Known Subclasses:
MultiItemSelector
,SingleItemSelector
public abstract class AbstractSelectorComponent<T,C extends AbstractSelectorComponent.SelectorComponentContext<T,I,C>,I extends Nameable & Matchable & Enableable & Selectable & Itemable<T>>
extends AbstractComponent<C>
Base component for selectors which provide selectable lists.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
AbstractSelectorComponent.BaseSelectorComponentContext<T,
I extends Nameable & Matchable & Itemable<T>, C extends AbstractSelectorComponent.SelectorComponentContext<T, I, C>> Base implementation of aAbstractSelectorComponent.SelectorComponentContext
.static class
Class keeping item state.static interface
AbstractSelectorComponent.SelectorComponentContext<T,
I extends Nameable & Matchable & Itemable<T>, C extends AbstractSelectorComponent.SelectorComponentContext<T, I, C>> Context interface on a selector component sharing content. -
Field Summary
Fields inherited from class org.springframework.shell.component.support.AbstractComponent
OPERATION_BACKSPACE, OPERATION_CHAR, OPERATION_DOWN, OPERATION_EXIT, OPERATION_SELECT, OPERATION_UNICODE, OPERATION_UP
-
Constructor Summary
ConstructorDescriptionAbstractSelectorComponent
(org.jline.terminal.Terminal terminal, String name, List<I> items, boolean exitSelects, Comparator<I> comparator) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
bindKeyMap
(org.jline.keymap.KeyMap<String> keyMap) Bind key map.Gets an item mapper.getItems()
Gets items.protected boolean
read
(org.jline.keymap.BindingReader bindingReader, org.jline.keymap.KeyMap<String> keyMap, C context) Read input.protected C
runInternal
(C context) Run internal logic called from public run method.void
setDefaultExpose
(I defaultExpose) Sets default expose item when component start.void
setItemMapper
(Function<T, String> itemMapper) Sets an item mapper.void
setMaxItems
(int maxItems) Set max items to show.Methods inherited from class org.springframework.shell.component.support.AbstractComponent
addPostRunHandler, addPreRunHandler, getTemplateExecutor, getTerminal, getThisContext, hasTty, loop, render, renderTemplateResource, run, runPostRunHandlers, runPreRunHandlers, setPrintResults, setRenderer, setResourceLoader, setTemplateExecutor, setTemplateLocation
-
Field Details
-
name
-
-
Constructor Details
-
AbstractSelectorComponent
public AbstractSelectorComponent(org.jline.terminal.Terminal terminal, String name, List<I> items, boolean exitSelects, Comparator<I> comparator)
-
-
Method Details
-
setMaxItems
public void setMaxItems(int maxItems) Set max items to show.- Parameters:
maxItems
- max items
-
setItemMapper
Sets an item mapper.- Parameters:
itemMapper
- the item mapper
-
getItemMapper
Gets an item mapper.- Returns:
-
setDefaultExpose
Sets default expose item when component start.- Parameters:
defaultExpose
- the default item
-
getItems
Gets items.- Returns:
- a list of items
-
bindKeyMap
Description copied from class:AbstractComponent
Bind key map.- Specified by:
bindKeyMap
in classAbstractComponent<C extends AbstractSelectorComponent.SelectorComponentContext<T,
I, C>>
-
runInternal
Description copied from class:AbstractComponent
Run internal logic called from public run method.- Specified by:
runInternal
in classAbstractComponent<C extends AbstractSelectorComponent.SelectorComponentContext<T,
I, C>> - Parameters:
context
- the context- Returns:
- a context
-
read
protected boolean read(org.jline.keymap.BindingReader bindingReader, org.jline.keymap.KeyMap<String> keyMap, C context) Description copied from class:AbstractComponent
Read input.- Specified by:
read
in classAbstractComponent<C extends AbstractSelectorComponent.SelectorComponentContext<T,
I, C>> - Parameters:
bindingReader
- the binding readerkeyMap
- the key mapcontext
- the context- Returns:
- true if read is complete, false to stop
-