Class GenericResponse<T>

java.lang.Object
org.chenile.base.response.GenericResponse<T>
Type Parameters:
T - - the actual payload type returned by the service
All Implemented Interfaces:
WarningAware

public class GenericResponse<T> extends Object implements WarningAware
A generic response that would be returned for all the services. It includes the payload returned by the service along with other information such as Http Status code, warnings and errors. This allows a comprehensive and consistent way of communicating with the rest of the world.
This can be used across protocols though it uses the Http status code
  • Field Details

  • Constructor Details

    • GenericResponse

      public GenericResponse()
    • GenericResponse

      public GenericResponse(ResponseMessage message)
    • GenericResponse

      public GenericResponse(T data)
      Construct a response with the given payload.
      Set success to true
      By default, call setCode(int) to HTTP status OK. It will be over-ridden later if required from the success and warning error codes that are set in OperationDefinition
      Parameters:
      data - the payload of the response
  • Method Details

    • isSuccess

      public boolean isSuccess()
    • setSuccess

      public void setSuccess(boolean success)
    • getCode

      public int getCode()
    • setCode

      public void setCode(int errorCode)
    • getSeverity

      public ErrorType getSeverity()
    • setSeverity

      public void setSeverity(ErrorType severity)
    • getDescription

      public String getDescription()
    • setDescription

      public void setDescription(String message)
    • getData

      public T getData()
    • setData

      public void setData(T data)
    • getSubErrorCode

      public int getSubErrorCode()
    • setSubErrorCode

      public void setSubErrorCode(int subErrorCode)
    • getErrors

      public List<ResponseMessage> getErrors()
    • addWarningMessage

      public void addWarningMessage(ResponseMessage m)
      Specified by:
      addWarningMessage in interface WarningAware
    • getWarningMessages

      public List<ResponseMessage> getWarningMessages()
      Specified by:
      getWarningMessages in interface WarningAware
    • removeAllWarnings

      public void removeAllWarnings()
      Specified by:
      removeAllWarnings in interface WarningAware