public abstract class AbstractComponent<T extends ComponentContext<T>> extends Object implements org.springframework.context.ResourceLoaderAware
Modifier and Type | Field and Description |
---|---|
static String |
OPERATION_BACKSPACE |
static String |
OPERATION_CHAR |
static String |
OPERATION_DOWN |
static String |
OPERATION_EXIT |
static String |
OPERATION_SELECT |
static String |
OPERATION_UP |
Constructor and Description |
---|
AbstractComponent(org.jline.terminal.Terminal terminal) |
Modifier and Type | Method and Description |
---|---|
void |
addPostRunHandler(Consumer<T> handler)
Adds a post-run handler.
|
void |
addPreRunHandler(Consumer<T> handler)
Adds a pre-run handler.
|
protected abstract void |
bindKeyMap(org.jline.keymap.KeyMap<String> keyMap)
Bind key map.
|
TemplateExecutor |
getTemplateExecutor()
Gets a template executor.
|
org.jline.terminal.Terminal |
getTerminal()
Gets a
Terminal . |
abstract T |
getThisContext(ComponentContext<?> context)
Gets a real component context using common this trick.
|
protected boolean |
hasTty()
Checks if this component has an existing
tty . |
protected void |
loop(ComponentContext<?> context)
Enter into read loop.
|
protected abstract boolean |
read(org.jline.keymap.BindingReader bindingReader,
org.jline.keymap.KeyMap<String> keyMap,
T context)
Read input.
|
List<org.jline.utils.AttributedString> |
render(T context)
Render to be shows content of a display with set display renderer using a
given context.
|
protected List<org.jline.utils.AttributedString> |
renderTemplateResource(Map<String,Object> attributes)
Render a given template with attributes.
|
T |
run(ComponentContext<?> context)
Runs a component logic with a given context and returns updated context.
|
protected abstract T |
runInternal(T context)
Run internal logic called from public run method.
|
protected T |
runPostRunHandlers(T context)
Run post-run handlers
|
protected T |
runPreRunHandlers(T context)
Run pre-run handlers
|
void |
setPrintResults(boolean printResults)
Sets if results should be printed into a console, Defaults to
true . |
void |
setRenderer(Function<T,List<org.jline.utils.AttributedString>> renderer)
Sets a display renderer.
|
void |
setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader) |
void |
setTemplateExecutor(TemplateExecutor templateExecutor)
Sets a template executor.
|
void |
setTemplateLocation(String templateLocation)
Sets a template location.
|
public static final String OPERATION_EXIT
public static final String OPERATION_BACKSPACE
public static final String OPERATION_CHAR
public static final String OPERATION_SELECT
public static final String OPERATION_DOWN
public static final String OPERATION_UP
public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
setResourceLoader
in interface org.springframework.context.ResourceLoaderAware
public org.jline.terminal.Terminal getTerminal()
Terminal
.public void setRenderer(Function<T,List<org.jline.utils.AttributedString>> renderer)
renderer
- the display renderer functionpublic List<org.jline.utils.AttributedString> render(T context)
context
- the contextpublic void addPreRunHandler(Consumer<T> handler)
handler
- the handlerpublic void addPostRunHandler(Consumer<T> handler)
handler
- the handlerpublic void setPrintResults(boolean printResults)
true
.printResults
- flag setting if results are printedpublic final T run(ComponentContext<?> context)
context
- the contextpublic TemplateExecutor getTemplateExecutor()
public void setTemplateExecutor(TemplateExecutor templateExecutor)
templateExecutor
- the template executorpublic void setTemplateLocation(String templateLocation)
templateLocation
- the template locationprotected boolean hasTty()
tty
.protected List<org.jline.utils.AttributedString> renderTemplateResource(Map<String,Object> attributes)
attributes
- the attributespublic abstract T getThisContext(ComponentContext<?> context)
context
- the contextprotected abstract boolean read(org.jline.keymap.BindingReader bindingReader, org.jline.keymap.KeyMap<String> keyMap, T context)
bindingReader
- the binding readerkeyMap
- the key mapcontext
- the contextprotected abstract T runInternal(T context)
context
- the contextprotected abstract void bindKeyMap(org.jline.keymap.KeyMap<String> keyMap)
keyMap
- protected void loop(ComponentContext<?> context)
context
- the contextprotected T runPreRunHandlers(T context)
context
- the contextCopyright © 2024. All rights reserved.