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>
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 -
Method Summary
Modifier and TypeMethodDescriptiongetError()Get the exception object thrown by this API callback if any.Get the result from the API callback.booleanWas 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
-
Constructor Details
-
APICallBackCatcher
public APICallBackCatcher()
-
-
Method Details
-
getResult
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
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
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
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
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
-