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 Details

    • empty

      static <C extends ComponentContext<C>> ComponentContext<C> empty()
      Gets an empty context.
      Type Parameters:
      C - the type of context
      Returns:
      empty context
    • get

      <T> T get(Object key)
      Gets a value from a context.
      Type Parameters:
      T - the type of context
      Parameters:
      key - the key
      Returns:
      a value
    • get

      <T> T get(Object key, Class<T> type)
      Gets a value from a context with a given type to get cast to.
      Type Parameters:
      T - the type of context
      Parameters:
      key - the key
      type - the class type
      Returns:
      a value
    • containsKey

      boolean containsKey(Object key)
      Check if a context contains a key.
      Parameters:
      key - the key
      Returns:
      true if context contains key
    • put

      ComponentContext<C> put(Object key, Object value)
      Put an entry into a context.
      Parameters:
      key - the entry key
      value - the entry value
      Returns:
      a context
    • stream

      Stream key/value pairs from this ComponentContext
      Returns:
      a Stream of key/value pairs held by this context
    • getTerminalWidth

      Integer getTerminalWidth()
      Get terminal width.
      Returns:
      a terminal width
    • setTerminalWidth

      void setTerminalWidth(Integer terminalWidth)
      Set terminal width.
      Parameters:
      terminalWidth - the width
    • toTemplateModel

      Map<String,Object> 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