Interface ComponentContext<C extends ComponentContext<C>>
- All Known Subinterfaces:
AbstractSelectorComponent.SelectorComponentContext<T,
,I, C> AbstractTextComponent.TextComponentContext<T,
,C> ConfirmationInput.ConfirmationInputContext
,MultiItemSelector.MultiItemSelectorContext<T,
,I> PathInput.PathInputContext
,PathSearch.PathSearchContext
,SingleItemSelector.SingleItemSelectorContext<T,
,I> StringInput.StringInputContext
- All Known Implementing Classes:
AbstractSelectorComponent.BaseSelectorComponentContext
,AbstractTextComponent.BaseTextComponentContext
,BaseComponentContext
public interface ComponentContext<C extends ComponentContext<C>>
Contract for base component context having access to basic key/value pairs.
This is a base context which components can extend to provide their own
component spesific contexts.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(Object key) Check if a context contains a key.static <C extends ComponentContext<C>>
ComponentContext<C>empty()
Gets an empty context.<T> T
Gets a value from a context.<T> T
Gets a value from a context with a given type to get cast to.Get terminal width.Put an entry into a context.void
setTerminalWidth
(Integer terminalWidth) Set terminal width.stream()
Stream key/value pairs from thisComponentContext
Gets context values as a map.
-
Method Details
-
empty
Gets an empty context.- Type Parameters:
C
- the type of context- Returns:
- empty context
-
get
Gets a value from a context.- Type Parameters:
T
- the type of context- Parameters:
key
- the key- Returns:
- a value
-
get
Gets a value from a context with a given type to get cast to.- Type Parameters:
T
- the type of context- Parameters:
key
- the keytype
- the class type- Returns:
- a value
-
containsKey
Check if a context contains a key.- Parameters:
key
- the key- Returns:
- true if context contains key
-
put
Put an entry into a context.- Parameters:
key
- the entry keyvalue
- the entry value- Returns:
- a context
-
stream
Stream key/value pairs from thisComponentContext
- Returns:
- a
Stream
of key/value pairs held by this context
-
getTerminalWidth
Integer getTerminalWidth()Get terminal width.- Returns:
- a terminal width
-
setTerminalWidth
Set terminal width.- Parameters:
terminalWidth
- the width
-
toTemplateModel
Gets context values as a map. Every context implementation can do their own model as essentially what matter is a one coming out from a last child which is one most likely to feed into a template engine.- Returns:
- map of context values
-