Class ResponseHandler<T>

java.lang.Object
org.stellar.sdk.requests.ResponseHandler<T>

public class ResponseHandler<T> extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    ResponseHandler(com.google.gson.reflect.TypeToken<T> type)
    "Generics on a type are typically erased at runtime, except when the type is compiled with the generic parameter bound.
  • Method Summary

    Modifier and Type
    Method
    Description
    handleResponse(okhttp3.Response response)
    Handles the HTTP response and converts it to the appropriate object or throws exceptions based on the response status.
    handleResponse(okhttp3.Response response, boolean submitTransactionAsync)
    Handles the HTTP response and converts it to the appropriate object or throws exceptions based on the response status.

    Methods inherited from class java.lang.Object

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

    • ResponseHandler

      public ResponseHandler(com.google.gson.reflect.TypeToken<T> type)
      "Generics on a type are typically erased at runtime, except when the type is compiled with the generic parameter bound. In that case, the compiler inserts the generic type information into the compiled class. In other cases, that is not possible." More info: http://stackoverflow.com/a/14506181
      Parameters:
      type -
  • Method Details

    • handleResponse

      public T handleResponse(okhttp3.Response response)
      Handles the HTTP response and converts it to the appropriate object or throws exceptions based on the response status.
      Parameters:
      response - The HTTP response to handle
      Returns:
      The parsed object of type T
      Throws:
      TooManyRequestsException - If the response code is 429 (Too Many Requests)
      UnexpectedException - If the response body is empty or there's an unexpected error reading the response
      BadRequestException - If the response code is in the 4xx range
      BadResponseException - If the response code is in the 5xx range
    • handleResponse

      public T handleResponse(okhttp3.Response response, boolean submitTransactionAsync)
      Handles the HTTP response and converts it to the appropriate object or throws exceptions based on the response status.
      Parameters:
      response - The HTTP response to handle
      submitTransactionAsync - Only set it to true when calling Server.submitTransactionXdrAsync(String).
      Returns:
      The parsed object of type T
      Throws:
      TooManyRequestsException - If the response code is 429 (Too Many Requests)
      UnexpectedException - If the response body is empty or there's an unexpected error reading the response
      BadRequestException - If the response code is in the 4xx range
      BadResponseException - If the response code is in the 5xx range