Class ActionResult

java.lang.Object
com.scivicslab.pojoactor.core.ActionResult

public class ActionResult extends Object
Represents the result of executing an action on an actor.

This class encapsulates the outcome of an action execution, including whether it succeeded and any result message or data. It is primarily used with CallableByActionName for string-based method invocation.

Usage Example


 public class MathPlugin implements CallableByActionName {
     @Override
     public ActionResult callByActionName(String actionName, String args) {
         if ("add".equals(actionName)) {
             String[] parts = args.split(",");
             int result = Integer.parseInt(parts[0]) + Integer.parseInt(parts[1]);
             return new ActionResult(true, String.valueOf(result));
         }
         return new ActionResult(false, "Unknown action: " + actionName);
     }
 }
 
Since:
2.0.0, 2.0.0
Author:
devteam@scivicslab.com
See Also:
  • Constructor Details

    • ActionResult

      public ActionResult(boolean success, String result)
      Constructs a new ActionResult.
      Parameters:
      success - true if the action completed successfully, false otherwise
      result - a message or data describing the action result
  • Method Details

    • isSuccess

      public boolean isSuccess()
      Returns whether the action completed successfully.
      Returns:
      true if successful, false otherwise
    • getResult

      public String getResult()
      Returns the result message or data.
      Returns:
      the result string
    • toString

      public String toString()
      Overrides:
      toString in class Object