Class ToolResult

java.lang.Object
org.snmp4j.mcp.tool.ToolResult

public class ToolResult extends Object
Represents the result of a tool execution.
Since:
0.0.1
Version:
0.1.0
Author:
SNMP4J.org
  • Constructor Details

    • ToolResult

      public ToolResult(boolean success, Object result, String message)
      Creates a new tool result.
      Parameters:
      success - whether the execution was successful
      result - the result data
      message - the result message
  • Method Details

    • success

      public static ToolResult success(Object result)
      Creates a successful result.
      Parameters:
      result - the result data
      Returns:
      a tool result
    • success

      public static ToolResult success(Object result, String message)
      Creates a successful result with a message.
      Parameters:
      result - the result data
      message - the success message
      Returns:
      a tool result
    • failure

      public static ToolResult failure(String message)
      Creates a failed result.
      Parameters:
      message - the error message
      Returns:
      a tool result
    • failure

      public static ToolResult failure(String message, Object result)
      Creates a failed result with result data.
      Parameters:
      message - the error message
      result - the result data (may contain partial results)
      Returns:
      a tool result
    • isSuccess

      public boolean isSuccess()
      Checks if the execution was successful.
      Returns:
      true if successful, false otherwise
    • getResult

      public Object getResult()
      Gets the result data.
      Returns:
      the result data
    • getMessage

      public String getMessage()
      Gets the result message.
      Returns:
      the result message
    • addData

      public ToolResult addData(String key, Object value)
      Adds additional data to the result.
      Parameters:
      key - the data key
      value - the data value
      Returns:
      this result for chaining
    • getData

      public Object getData(String key)
      Gets additional data by key.
      Parameters:
      key - the data key
      Returns:
      the data value, or null if not found
    • getAllData

      public Map<String,Object> getAllData()
      Gets all additional data.
      Returns:
      the additional data map