Class APICallBackCatcher<T>
- java.lang.Object
-
- com.moesif.api.controllers.syncwrapper.SynchronousBase
-
- com.moesif.api.controllers.syncwrapper.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 Summary
Constructors Constructor Description APICallBackCatcher()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ThrowablegetError()Get the exception object thrown by this API callback if any.TgetResult()Get the result from the API callback.booleanisSuccess()Was the API call successful? Blocks if API call is not complete yet.voidonFailure(HttpContext responseContext, Throwable error)OnFailure handler for APICallBack.voidonSuccess(HttpContext context, T response)On Success handler for APICallBack.-
Methods inherited from class com.moesif.api.controllers.syncwrapper.SynchronousBase
await, await, markAsDone
-
-
-
-
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 InterruptedExceptionWas 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:
onSuccessin interfaceAPICallBack<T>- Parameters:
context- The context of the API requestresponse- The response received from the API Call
-
onFailure
public void onFailure(HttpContext responseContext, Throwable error)
OnFailure handler for APICallBack.- Specified by:
onFailurein interfaceAPICallBack<T>- Parameters:
responseContext- The context of the API requesterror- Any error detected during the API Call and/or deserialization
-
-