Package com.tnsai.actions.model
Record Class ActionResponse
java.lang.Object
java.lang.Record
com.tnsai.actions.model.ActionResponse
- Record Components:
value- the result value (may be null on failure)success- whether the action completed successfullyerror- the error message (null on success)
Typed response from action execution.
Replaces the untyped Object return from
Agent.executeAction(String, Map) with a structured result
carrying success/failure status and an optional error message.
Usage:
ActionResponse response = agent.executeAction(request);
if (response.success()) {
Object data = response.value();
// process result
} else {
logger.error("Action failed: {}", response.error());
}
- Since:
- 0.3.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionActionResponse(Object value, boolean success, String error) Creates an instance of aActionResponserecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.error()Returns the value of theerrorrecord component.static ActionResponseCreates a failure response with the given error message.static ActionResponseCreates a failure response with the given error message and partial value.final inthashCode()Returns a hash code value for this object.booleansuccess()Returns the value of thesuccessrecord component.static ActionResponseCreates a successful response with the given value.final StringtoString()Returns a string representation of this record class.value()Returns the value of thevaluerecord component.
-
Constructor Details
-
Method Details
-
success
Creates a successful response with the given value.- Parameters:
value- the result value- Returns:
- a successful ActionResponse
-
failure
Creates a failure response with the given error message.- Parameters:
error- the error message (must not be null)- Returns:
- a failed ActionResponse
-
failure
Creates a failure response with the given error message and partial value.- Parameters:
error- the error message (must not be null)partialValue- any partial result available despite the failure- Returns:
- a failed ActionResponse
-
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. -
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. -
equals
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
value
Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-
success
public boolean success()Returns the value of thesuccessrecord component.- Returns:
- the value of the
successrecord component
-
error
Returns the value of theerrorrecord component.- Returns:
- the value of the
errorrecord component
-