Class AbstractTelegramRequest
- java.lang.Object
-
- com.jtelegram.api.requests.framework.AbstractTelegramRequest
-
- All Implemented Interfaces:
TelegramRequest
- Direct Known Subclasses:
QueryTelegramRequest,UpdateTelegramRequest
public abstract class AbstractTelegramRequest extends java.lang.Object implements TelegramRequest
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.function.Consumer<TelegramException>errorHandlerprotected static com.google.gson.Gsongson-
Fields inherited from interface com.jtelegram.api.requests.framework.TelegramRequest
JSON_MEDIA_TYPE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractTelegramRequest(java.lang.String endPoint, java.util.function.Consumer<TelegramException> errorHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanEqual(java.lang.Object other)booleanequals(java.lang.Object o)protected java.lang.StringgetBody(okhttp3.Response response)java.lang.StringgetEndPoint()Get the appropriate endpoint for this request.protected voidhandleError(TelegramException ex)voidhandleException(java.io.IOException ex)Handle an exception in the case that an I/O error occuredinthashCode()java.lang.Stringserialize()Use GSON to properly serialize the request to send to Telegram's servers.voidsetErrorHandler(java.util.function.Consumer<TelegramException> errorHandler)protected com.google.gson.JsonElementvalidate(java.lang.String response)-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.jtelegram.api.requests.framework.TelegramRequest
build, handleResponse
-
-
-
-
Field Detail
-
gson
protected static transient com.google.gson.Gson gson
-
errorHandler
protected transient java.util.function.Consumer<TelegramException> errorHandler
-
-
Constructor Detail
-
AbstractTelegramRequest
protected AbstractTelegramRequest(java.lang.String endPoint, java.util.function.Consumer<TelegramException> errorHandler)
-
-
Method Detail
-
handleError
protected void handleError(TelegramException ex)
-
getBody
protected java.lang.String getBody(okhttp3.Response response) throws java.io.IOException- Throws:
java.io.IOException
-
validate
protected com.google.gson.JsonElement validate(java.lang.String response)
-
getEndPoint
public java.lang.String getEndPoint()
Description copied from interface:TelegramRequestGet the appropriate endpoint for this request.- Specified by:
getEndPointin interfaceTelegramRequest- Returns:
- The endpoint
-
serialize
public java.lang.String serialize()
Description copied from interface:TelegramRequestUse GSON to properly serialize the request to send to Telegram's servers. This method exists if there are any special cases or pre-processing required.- Specified by:
serializein interfaceTelegramRequest- Returns:
- the serialized JSON string
-
handleException
public void handleException(java.io.IOException ex)
Description copied from interface:TelegramRequestHandle an exception in the case that an I/O error occured- Specified by:
handleExceptionin interfaceTelegramRequest- Parameters:
ex- The exception
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
canEqual
protected boolean canEqual(java.lang.Object other)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
setErrorHandler
public void setErrorHandler(java.util.function.Consumer<TelegramException> errorHandler)
-
-