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>
errorHandler
protected static com.google.gson.Gson
gson
-
Fields inherited from interface com.jtelegram.api.requests.framework.TelegramRequest
JSON_MEDIA_TYPE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractTelegramRequest(java.lang.String endPoint, java.util.function.Consumer<TelegramException> errorHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
canEqual(java.lang.Object other)
boolean
equals(java.lang.Object o)
protected java.lang.String
getBody(okhttp3.Response response)
java.lang.String
getEndPoint()
Get the appropriate endpoint for this request.protected void
handleError(TelegramException ex)
void
handleException(java.io.IOException ex)
Handle an exception in the case that an I/O error occuredint
hashCode()
java.lang.String
serialize()
Use GSON to properly serialize the request to send to Telegram's servers.void
setErrorHandler(java.util.function.Consumer<TelegramException> errorHandler)
protected com.google.gson.JsonElement
validate(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:TelegramRequest
Get the appropriate endpoint for this request.- Specified by:
getEndPoint
in interfaceTelegramRequest
- Returns:
- The endpoint
-
serialize
public java.lang.String serialize()
Description copied from interface:TelegramRequest
Use 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:
serialize
in interfaceTelegramRequest
- Returns:
- the serialized JSON string
-
handleException
public void handleException(java.io.IOException ex)
Description copied from interface:TelegramRequest
Handle an exception in the case that an I/O error occured- Specified by:
handleException
in interfaceTelegramRequest
- Parameters:
ex
- The exception
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
canEqual
protected boolean canEqual(java.lang.Object other)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
setErrorHandler
public void setErrorHandler(java.util.function.Consumer<TelegramException> errorHandler)
-
-