Class APICallBackCatcher<T>

  • Type Parameters:
    T - Type of the response object
    All Implemented Interfaces:
    APICallBack<T>

    public class APICallBackCatcher<T>
    extends SynchronousBase
    implements APICallBack<T>
    An APICallBack that captures the HTTP response and can be waited on An instance of this class can be passed to an API call as the APICallBack instance to capture the results of that call. Call await() to block until completion of the API call. Trying to get results of API call before calling wait() will also block.
    • Constructor Detail

      • APICallBackCatcher

        public APICallBackCatcher()
    • Method Detail

      • getResult

        public T getResult()
                    throws Throwable
        Get the result from the API callback. Blocks if API call is not complete yet.
        Returns:
        result
        Throws:
        Throwable - error waiting for tasks to complete
      • getError

        public Throwable getError()
                           throws InterruptedException
        Get the exception object thrown by this API callback if any. Blocks if API call is not complete yet.
        Returns:
        the error object
        Throws:
        InterruptedException - error waiting for tasks to complete
      • isSuccess

        public boolean isSuccess()
                          throws InterruptedException
        Was the API call successful? Blocks if API call is not complete yet.
        Returns:
        true if successful
        Throws:
        InterruptedException - error waiting for tasks to complete
      • onSuccess

        public void onSuccess​(HttpContext context,
                              T response)
        On Success handler for APICallBack.
        Specified by:
        onSuccess in interface APICallBack<T>
        Parameters:
        context - The context of the API request
        response - The response received from the API Call
      • onFailure

        public void onFailure​(HttpContext responseContext,
                              Throwable error)
        OnFailure handler for APICallBack.
        Specified by:
        onFailure in interface APICallBack<T>
        Parameters:
        responseContext - The context of the API request
        error - Any error detected during the API Call and/or deserialization