Class ActionResult

java.lang.Object
com.tnsai.actions.ActionResult

public class ActionResult extends Object
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 Details

    • ActionResult

      public ActionResult(Object value)
  • Method Details

    • getValue

      public Object getValue()
      Get the raw value.
      Returns:
      The raw result value
    • asString

      public String asString()
      Get value as String.
      Returns:
      String representation of the value
    • asMap

      public Map<String,Object> asMap()
      Get value as Map.
      Returns:
      Value as Map, or null if conversion fails
    • asList

      public List<Object> 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

      public <T> T as(Class<T> clazz)
      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

      public String toString()
      Overrides:
      toString in class Object