Package com.tnsai.actions
Class ActionResult
java.lang.Object
com.tnsai.actions.ActionResult
Wrapper for action execution results.
Allows developers to access and process the raw result from action execution (HTTP response, LLM tool output, etc.) within the action method body.
Usage example:
@ActionSpec(
type = WEB_SERVICE,
endpoint = "https://api.example.com/data/{id}"
)
public Object getData(String id, ActionResult result) {
// Option 1: Return as-is
return result;
// Option 2: Process and return custom format
Map<String, Object> json = result.asMap();
return json.get("name");
}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TGet value cast to specific type.com.fasterxml.jackson.databind.JsonNodeasJson()Get value as JsonNode for flexible JSON traversal.asList()Get value as List.asMap()Get value as Map.asString()Get value as String.getValue()Get the raw value.booleanisEmpty()Check if value is empty (null, empty string, empty collection).booleanisNull()Check if value is null.toString()
-
Constructor Details
-
ActionResult
-
-
Method Details
-
getValue
Get the raw value.- Returns:
- The raw result value
-
asString
Get value as String.- Returns:
- String representation of the value
-
asMap
Get value as Map.- Returns:
- Value as Map, or null if conversion fails
-
asList
Get value as List.- Returns:
- Value as List, or null if conversion fails
-
asJson
public com.fasterxml.jackson.databind.JsonNode asJson()Get value as JsonNode for flexible JSON traversal.- Returns:
- JsonNode representation, or null if conversion fails
-
as
Get value cast to specific type.- Type Parameters:
T- Target type- Parameters:
clazz- Target class- Returns:
- Value cast to target type, or null if conversion fails
-
isNull
public boolean isNull()Check if value is null.- Returns:
- true if value is null
-
isEmpty
public boolean isEmpty()Check if value is empty (null, empty string, empty collection).- Returns:
- true if value is empty
-
toString
-