Interface BotHandler

All Superinterfaces:
Comparable<BotHandler>

public interface BotHandler extends 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 Type
    Method
    Description
    default int
    Compares this handler to another for ordering purposes.
    default int
    Returns the priority order of this handler.
    void
    handle(BotRequest botRequest, BotResponse botResponse)
    Processes the incoming Telegram update encapsulated in the request and populates the response.
    boolean
    supports(BotRequest botRequest)
    Determines whether this handler is capable of processing the given request.
  • Method Details

    • compareTo

      default int compareTo(BotHandler o)
      Compares this handler to another for ordering purposes. Handlers with lower order values are evaluated first.
      Specified by:
      compareTo in interface Comparable<BotHandler>
      Parameters:
      o - the other BotHandler to compare to; must not be null
      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 to Integer.MAX_VALUE.
      Returns:
      the order value for this handler
    • supports

      boolean supports(BotRequest botRequest)
      Determines whether this handler is capable of processing the given request.
      Parameters:
      botRequest - the current request context containing the incoming update; must not be null
      Returns:
      true if this handler can process the request, false otherwise
    • handle

      void handle(BotRequest botRequest, BotResponse botResponse)
      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 be null
      botResponse - the mutable response object to which API methods may be added; must not be null