Class DiscoveredRoleActions

java.lang.Object
com.tnsai.metadata.DiscoveredRoleActions

@Immutable public final class DiscoveredRoleActions extends Object
Immutable container for actions discovered from a Role class via reflection. Contains all discovered actions from public methods annotated with @Action.

This class is used by ActionDiscovery to hold the results of reflection-based action discovery.

Following ADR-006: Immutable Models

Following ADR-002: Convention Over Configuration

  • Class name = Role name
  • Public methods with @Action = Actions
See Also:
  • Constructor Details

    • DiscoveredRoleActions

      public DiscoveredRoleActions(Class<?> roleClass, List<ActionMetadata> actions)
      Creates a container for discovered role actions.
      Parameters:
      roleClass - the Role class that was scanned
      actions - list of discovered actions from the role
      Throws:
      IllegalArgumentException - if roleClass or actions is null
  • Method Details

    • getName

      public String getName()
      Gets the role name (derived from class simple name).
      Returns:
      role name
    • getActionCount

      public int getActionCount()
      Gets the number of actions in this role.
      Returns:
      action count
    • hasActions

      public boolean hasActions()
      Checks if this role has any actions.
      Returns:
      true if actions list is not empty
    • findAction

      public ActionMetadata findAction(String actionName)
      Finds an action by name.
      Parameters:
      actionName - the action name to search for
      Returns:
      the action metadata, or null if not found
    • hasAction

      public boolean hasAction(String actionName)
      Checks if this role has a specific action.
      Parameters:
      actionName - the action name to check
      Returns:
      true if action exists
    • getFullClassName

      public String getFullClassName()
      Gets the fully qualified class name.
      Returns:
      fully qualified class name
    • getActionNames

      public List<String> getActionNames()
      Gets all action names.
      Returns:
      list of action names
    • getActions

      public List<ActionMetadata> getActions()
      Gets all discovered actions as an immutable list.

      Renderers and prompt builders that need to iterate the full metadata (parameters, return type, action type, type-specific fields like endpoint/MCP-server-uri) consume this. The original API only exposed name-only / single-action accessors which forced downstream callers to either re-run reflection or accept lossy rendering — see issue surfaced when SystemPromptBuilder couldn't mirror RolePromptBuilder's action section.

      Returns:
      immutable list of discovered actions; never null
    • toPromptString

      public String toPromptString()
      Creates a formatted string for prompt generation. Lists all actions with their signatures.
      Returns:
      formatted role string