Package com.tnsai.metadata
Class DiscoveredRoleActions
java.lang.Object
com.tnsai.metadata.DiscoveredRoleActions
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 Summary
ConstructorsConstructorDescriptionDiscoveredRoleActions(Class<?> roleClass, List<ActionMetadata> actions) Creates a container for discovered role actions. -
Method Summary
Modifier and TypeMethodDescriptionfindAction(String actionName) Finds an action by name.intGets the number of actions in this role.Gets all action names.Gets all discovered actions as an immutable list.Gets the fully qualified class name.getName()Gets the role name (derived from class simple name).booleanChecks if this role has a specific action.booleanChecks if this role has any actions.Creates a formatted string for prompt generation.
-
Constructor Details
-
DiscoveredRoleActions
Creates a container for discovered role actions.- Parameters:
roleClass- the Role class that was scannedactions- list of discovered actions from the role- Throws:
IllegalArgumentException- if roleClass or actions is null
-
-
Method Details
-
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
Finds an action by name.- Parameters:
actionName- the action name to search for- Returns:
- the action metadata, or null if not found
-
hasAction
Checks if this role has a specific action.- Parameters:
actionName- the action name to check- Returns:
- true if action exists
-
getFullClassName
Gets the fully qualified class name.- Returns:
- fully qualified class name
-
getActionNames
Gets all action names.- Returns:
- list of action names
-
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
SystemPromptBuildercouldn't mirrorRolePromptBuilder's action section.- Returns:
- immutable list of discovered actions; never null
-
toPromptString
Creates a formatted string for prompt generation. Lists all actions with their signatures.- Returns:
- formatted role string
-