Class Response

java.lang.Object
com.oorian.messaging.responses.Response
Direct Known Subclasses:
ClientFileUploadStatusResponse

public abstract class Response extends Object
Abstract base class for all server-side responses in the Oorian messaging framework.

This class provides the foundation for creating structured JSON responses that are sent from the server to clients. All response types must extend this class and implement the toJson() method to define their specific JSON structure.

Features:

  • Unique response identification system
  • Standardized JSON response generation
  • Type-safe response hierarchy through inheritance
  • Consistent response structure across all response types

Usage:

To create a custom response type, extend this class and implement the toJson() method:


 public class CustomResponse extends Response {
     public CustomResponse(String responseId) {
         super(responseId);
     }

     @Override
     public JsonObject toJson() {
         JsonObject json = new JsonObject();
         json.put("id", getResponseId());
         // Add custom JSON structure
         return json;
     }
 }
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Response

      public Response(String responseId)
      Constructs a new Response with the specified response identifier.

      The response ID should uniquely identify the type of response being created and is used by clients to determine how to process the response data.

      Parameters:
      responseId - the unique identifier for this response type (e.g., "update", "addition", "deletion")
  • Method Details

    • getResponseId

      public String getResponseId()
      Returns the unique identifier for this response.

      This identifier is used to classify the response type and is typically included in the JSON representation of the response.

      Returns:
      the response identifier string
    • toJson

      public abstract JsonObject toJson()
      Generates and returns the JSON representation of this response.

      Subclasses must implement this method to define the specific JSON structure for their response type. The returned JsonObject should contain all necessary data and properties that the client needs to process the response.

      Returns:
      a JsonObject representing the complete JSON structure of this response
      Throws:
      ElementException - if an error occurs during JSON generation