Interface PromptResult<T extends Prompt>

    • Method Detail

      • getResult

        java.lang.String getResult()
        Get the raw result value as a string representation.

        This method returns the user's response in its most basic string form. For selection-based prompts (list, checkbox, choice), this typically returns the ID(s) of selected items. For input prompts, this returns the entered text.

        Examples:

        • List prompt: "option1"
        • Checkbox prompt: "[option1, option3]"
        • Input prompt: "user entered text"
        • Confirm prompt: "YES" or "NO"
        Returns:
        the result as a string, never null
      • getDisplayResult

        default java.lang.String getDisplayResult()
        Get a human-readable display representation of the result.

        This method returns a formatted version of the result that is suitable for display to users. It may differ from getResult() by providing more descriptive text or better formatting.

        The default implementation returns the same value as getResult(). Specific result types may override this to provide more user-friendly formatting.

        Returns:
        a display-friendly representation of the result, never null
      • getPrompt

        default T getPrompt()
        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));
         }
         
        Returns:
        the prompt that generated this result, or null if not available
        See Also:
        Prompt