Record Class ActionRequest

java.lang.Object
java.lang.Record
com.tnsai.actions.model.ActionRequest
Record Components:
actionName - the name of the action to execute (must not be null or blank)
parameters - the action parameters (never null, may be empty)

public record ActionRequest(String actionName, Map<String,Object> parameters) extends Record
Typed request for action execution.

Replaces raw Map<String, Object> parameters with a compile-time safe record. The parameters map is kept internally for now (Phase 1) — individual parameter types will be refined in later phases.

Usage:


 // Create from name and parameters
 ActionRequest request = ActionRequest.of("searchWeb", Map.of(
     "query", "Java frameworks",
     "maxResults", 10
 ));

 // Create without parameters
 ActionRequest request = ActionRequest.of("getStatus");

 // Use with Agent
 ActionResponse response = agent.executeAction(request);
 
Since:
0.3.0
See Also:
  • Constructor Details

    • ActionRequest

      public ActionRequest(String actionName, Map<String,Object> parameters)
      Compact constructor with validation.
  • Method Details

    • of

      public static ActionRequest of(String name, Map<String,Object> params)
      Creates an ActionRequest with the given name and parameters.
      Parameters:
      name - the action name
      params - the action parameters (null treated as empty)
      Returns:
      a new ActionRequest
    • of

      public static ActionRequest of(String name)
      Creates an ActionRequest with no parameters.
      Parameters:
      name - the action name
      Returns:
      a new ActionRequest with empty parameters
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • actionName

      public String actionName()
      Returns the value of the actionName record component.
      Returns:
      the value of the actionName record component
    • parameters

      public Map<String,Object> parameters()
      Returns the value of the parameters record component.
      Returns:
      the value of the parameters record component