Class Reply

  • All Implemented Interfaces:
    Serializable

    public class Reply
    extends Agent
    implements Serializable
    Represents a reply returned to the sender of an Agent during synchronous or asynchronous communication.

    A reply contains a success indicator, an optional exception, a message, and an HTTP response code. It also indicates whether additional replies are expected.

    Reply extends Agent, allowing it to carry agent data and latency information.

    Author:
    Charles B. Kozoyed
    See Also:
    Serialized Form
    • Constructor Detail

      • Reply

        public Reply()
        Constructs a reply with default values.

        By default, the reply indicates success, is marked as the last reply, has the message "OK", and has an HTTP response code of 200.

    • Method Detail

      • setException

        public final void setException​(Throwable throwable)
        Sets the exception associated with this reply.
        Parameters:
        throwable - the exception or other throwable, or null if no exception is associated with the reply
      • setSuccess

        public final void setSuccess​(boolean success)
        Sets whether the operation completed successfully.
        Parameters:
        success - true if successful; false otherwise
      • setMessage

        public final void setMessage​(String message)
        Sets the message associated with this reply.
        Parameters:
        message - the non-null, non-blank message
        Throws:
        IllegalArgumentException - if the message is null or blank
      • getException

        public final Throwable getException()
        Returns the exception associated with this reply.
        Returns:
        the exception or other throwable, or null if none was provided
      • isSuccess

        public final boolean isSuccess()
        Indicates whether the operation completed successfully.
        Returns:
        true if successful; false otherwise
      • isLastReply

        public final boolean isLastReply()
        Indicates whether this is the final reply in the reply sequence.
        Returns:
        true if this is the last reply; false otherwise
      • setLastReply

        public void setLastReply​(boolean lastReply)
        Sets whether this is the final reply for the in the reply sequence.
        Parameters:
        lastReply - true if this is the last reply; false otherwise
      • getMessage

        public final String getMessage()
        Returns the message associated with this reply.
        Returns:
        the reply message
      • getHttpResponseCode

        public int getHttpResponseCode()
        Returns the HTTP response code associated with this reply.

        KDC does not restrict this value to standard HTTP status codes.

        Returns:
        the HTTP response code
      • setHttpResponseCode

        public void setHttpResponseCode​(int httpResponseCode)
        Sets the HTTP response code associated with this reply.

        KDC does not restrict this value to standard HTTP status codes.

        Parameters:
        httpResponseCode - the HTTP response code