Class Response<T>

java.lang.Object
net.solarnetwork.domain.Result<T>
net.solarnetwork.web.domain.Response<T>
Type Parameters:
T - the object type

public class Response<T> extends net.solarnetwork.domain.Result<T>
A simple service response envelope object.
Version:
1.1
Author:
matt
  • Nested Class Summary

    Nested classes/interfaces inherited from class net.solarnetwork.domain.Result

    net.solarnetwork.domain.Result.ErrorDetail
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a successful response with no data.
    Response(Boolean success, String code, String message, T data)
    Constructor.
    Response(T data)
    Construct a successful response with just data.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <V> Response<V>
    response(V data)
    Helper method to construct instance using generic return type inference.

    Methods inherited from class net.solarnetwork.domain.Result

    error, error, error, error, getCode, getData, getErrors, getMessage, getSuccess, result, success, success

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Response

      public Response()
      Construct a successful response with no data.
    • Response

      public Response(T data)
      Construct a successful response with just data.
      Parameters:
      data - the data
    • Response

      public Response(Boolean success, String code, String message, T data)
      Constructor.
      Parameters:
      success - flag of success
      code - optional code, e.g. error code
      message - optional descriptive message
      data - optional data in the response
  • Method Details

    • response

      public static <V> Response<V> response(V data)
      Helper method to construct instance using generic return type inference. If you import this static method, then in your code you can write return response(myData) instead of new Response&lt;Object&gt;(myData).
      Type Parameters:
      V - the response data type
      Parameters:
      data - the data
      Returns:
      the response