Class Response<T extends TdApi.Object>
java.lang.Object
dev.voroby.springframework.telegram.client.templates.response.Response<T>
Response wrapper for queries.
- Author:
- Pavel Vorobyev
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetError()Returns the TdApi.Object if it is not null, otherwise throws a TelegramClientTdApiException.<R extends TdApi.Object>
Response<R>Map, or transform, theTdApi.Objectif it exists insideResponseotherwise returnResponsewith existingTdApi.Error.onError(Consumer<TdApi.Error> action) Performs an action in case of an error and returns currentResponse<T extends TdApi.Object>.Performs an action upon a successful function call to TDLib and returns currentResponse<T extends TdApi.Object>.
-
Constructor Details
-
Response
- Parameters:
object-TdApi.ObjectQuery response.error-TdApi.ErrorQuery error.
-
-
Method Details
-
map
Map, or transform, theTdApi.Objectif it exists insideResponseotherwise returnResponsewith existingTdApi.Error.- Type Parameters:
R- type of newTdApi.Object- Parameters:
mapFunction- function to transformTdApi.Objectin response- Returns:
Response<R extends TdApi.Object>
-
onSuccess
Performs an action upon a successful function call to TDLib and returns currentResponse<T extends TdApi.Object>.- Parameters:
action- callback called upon a successful function call of query to TDLib- Returns:
Response<T extends TdApi.Object>
-
onError
Performs an action in case of an error and returns currentResponse<T extends TdApi.Object>.- Parameters:
action- callback called in case of an error of query to TDLib- Returns:
Response<T extends TdApi.Object>
-
getObject
-
getObjectOrThrow
Returns the TdApi.Object if it is not null, otherwise throws a TelegramClientTdApiException.- Returns:
- TdApi.Object
- Throws:
TelegramClientTdApiException- if the object is null
-
getError
-