Package com.naver.ads.network
Class BaseCaller
-
- All Implemented Interfaces:
-
com.naver.ads.network.Caller
public abstract class BaseCaller<TResponse extends Object> implements Caller<TResponse>
A base implementation of Caller.
-
-
Field Summary
Fields Modifier and Type Field Description private final Requestrequestprivate final Deferred<HttpRequest>rawRequest
-
Constructor Summary
Constructors Constructor Description BaseCaller(Request.Factory requestFactory, CancellationToken cancellationToken, Map<Object, Object> tags)Constructors a new BaseCaller instance. BaseCaller(Request.Factory requestFactory, CancellationToken cancellationToken)Constructors a new BaseCaller instance.
-
Method Summary
Modifier and Type Method Description final RequestgetRequest()the instance of Request. Deferred<HttpRequest>getRawRequest()the deferred instance of HttpRequest. BooleanisExecuted()Returns true if this caller has been either execute executed or enqueue enqueued. CallerStategetState()Returns the caller state. BooleanisCancellationRequested()Gets whether cancellation has been requested. Response<TResponse>execute()Synchronously send the request and return its response Unitenqueue(Caller.Callback<TResponse> callback)Asynchronously send the request and notify Callback of its response or if an error occurred talking to the server, creating the request, or processing the response abstract TResponseunmarshalResponseBody(String body)Deserialized the body string. -
-
Constructor Detail
-
BaseCaller
BaseCaller(Request.Factory requestFactory, CancellationToken cancellationToken, Map<Object, Object> tags)
Constructors a new BaseCaller instance.- Parameters:
requestFactory- the factory that creates the Request instance.
-
BaseCaller
BaseCaller(Request.Factory requestFactory, CancellationToken cancellationToken)
Constructors a new BaseCaller instance.- Parameters:
requestFactory- the factory that creates the Request instance.
-
-
Method Detail
-
getRequest
final Request getRequest()
the instance of Request.
-
getRawRequest
Deferred<HttpRequest> getRawRequest()
the deferred instance of HttpRequest.
-
isExecuted
Boolean isExecuted()
Returns true if this caller has been either execute executed or enqueue enqueued. It is an error to execute or enqueue a caller more than once.
-
getState
CallerState getState()
Returns the caller state.
-
isCancellationRequested
Boolean isCancellationRequested()
Gets whether cancellation has been requested.
-
execute
@WorkerThread() Response<TResponse> execute()
Synchronously send the request and return its response
- Returns:
the response
-
enqueue
Unit enqueue(Caller.Callback<TResponse> callback)
Asynchronously send the request and notify Callback of its response or if an error occurred talking to the server, creating the request, or processing the response
- Parameters:
callback- the callback that notify of its successful response or error
-
unmarshalResponseBody
abstract TResponse unmarshalResponseBody(String body)
Deserialized the body string.
- Parameters:
body- the body that will be deserialized.- Returns:
the deserialized body.
-
-
-
-