T
- the type of object to be expected as a result. For methods that return a collection
of resources it is required to use CMAArray
as the type.
Callback can be cancelled at any point using the cancel()
method, that will
prevent any future calls to onSuccess(T)
and
onFailure(RuntimeException)
.
public abstract class CMACallback<T>
extends java.lang.Object
CMAClient
asynchronous methods.
Implement the onSuccess(T)
method for cases where the request was successful, the result
object should be delivered as a parameter.
It is also possible, but not mandatory to override onFailure(java.lang.RuntimeException)
and provide an
implementation for handling errors.
Constructor and Description |
---|
CMACallback() |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels this callback.
|
boolean |
isCancelled() |
protected void |
onFailure(java.lang.RuntimeException exception)
Callback to be invoked in case the request was unsuccessful.
|
protected abstract void |
onSuccess(T result)
Callback to be invoked in case the request was successful.
|
protected abstract void onSuccess(T result)
result
- result objectprotected void onFailure(java.lang.RuntimeException exception)
exception{@link
- RuntimeException} instancepublic void cancel()
onSuccess(Object)
and
onFailure(RuntimeException)
methods. This action cannot be reversed.public boolean isCancelled()
Copyright © 2019 Contentful, GmbH.. All Rights Reserved.