Class AbstractPromptResult<T extends Prompt>

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractPromptResult​(T prompt)
      Create a new AbstractPromptResult with the given prompt.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void applyFilter​(java.lang.String filteredResult)
      Apply a filter to this result.
      T getPrompt()
      Get the prompt that generated this result.
      protected abstract java.lang.String getRawResult()
      Get the raw (unfiltered) result value.
      java.lang.String getResult()
      Returns the filtered result if a filter was applied, otherwise delegates to the subclass implementation via getRawResult().
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractPromptResult

        protected AbstractPromptResult​(T prompt)
        Create a new AbstractPromptResult with the given prompt.
        Parameters:
        prompt - the associated Prompt, or null if none
    • Method Detail

      • getPrompt

        public T getPrompt()
        Description copied from interface: PromptResult
        Get the prompt that generated this result.

        This method provides access to the original prompt configuration, allowing inspection of the prompt's properties such as available items, validation rules, or other configuration details.

        Example Usage:

        
         ListResult result = (ListResult) results.get("choice");
         ListPrompt prompt = result.getPrompt();
        
         if (prompt != null) {
             // Access prompt configuration
             String promptMessage = prompt.getMessage();
             List<ListItem> availableItems = prompt.getItems();
        
             // Validate selection against available options
             String selectedId = result.getSelectedId();
             boolean isValidSelection = availableItems.stream()
                 .anyMatch(item -> item.getName().equals(selectedId));
         }
         
        Specified by:
        getPrompt in interface PromptResult<T extends Prompt>
        Returns:
        the prompt that generated this result, or null if not available
        See Also:
        Prompt
      • applyFilter

        public void applyFilter​(java.lang.String filteredResult)
        Apply a filter to this result. If set, getResult() will return the filtered value instead of the original.
        Parameters:
        filteredResult - the filtered result value
      • getResult

        public final java.lang.String getResult()
        Returns the filtered result if a filter was applied, otherwise delegates to the subclass implementation via getRawResult().
        Specified by:
        getResult in interface PromptResult<T extends Prompt>
        Returns:
        the result as a string, never null
      • getRawResult

        protected abstract java.lang.String getRawResult()
        Get the raw (unfiltered) result value. Subclasses must implement this instead of getResult().
        Returns:
        the raw result value