Interface BotHandler
- All Superinterfaces:
Comparable<BotHandler>
Core strategy interface for processing incoming Telegram updates.
Each implementation declares which
BotRequest types it can process via
supports(BotRequest) and performs the actual processing in
handle(BotRequest, BotResponse).
Handlers are ordered by getOrder() so that a sorted list of handlers is
evaluated in priority sequence.- Since:
- 0.0.1
- Author:
- Islom Mirsaburov
-
Method Summary
Modifier and TypeMethodDescriptiondefault intCompares this handler to another for ordering purposes.default intgetOrder()Returns the priority order of this handler.voidhandle(BotRequest botRequest, BotResponse botResponse) Processes the incoming Telegram update encapsulated in the request and populates the response.booleansupports(BotRequest botRequest) Determines whether this handler is capable of processing the given request.
-
Method Details
-
compareTo
Compares this handler to another for ordering purposes. Handlers with lower order values are evaluated first.- Specified by:
compareToin interfaceComparable<BotHandler>- Parameters:
o- the otherBotHandlerto compare to; must not benull- Returns:
- a negative integer, zero, or a positive integer as this handler's order is less than, equal to, or greater than the other handler's order
-
getOrder
default int getOrder()Returns the priority order of this handler. Lower values indicate higher priority. Defaults toInteger.MAX_VALUE.- Returns:
- the order value for this handler
-
supports
Determines whether this handler is capable of processing the given request.- Parameters:
botRequest- the current request context containing the incoming update; must not benull- Returns:
trueif this handler can process the request,falseotherwise
-
handle
Processes the incoming Telegram update encapsulated in the request and populates the response.- Parameters:
botRequest- the current request context containing the incoming update; must not benullbotResponse- the mutable response object to which API methods may be added; must not benull
-