Interface BotFilter

All Superinterfaces:
Comparable<BotFilter>

public interface BotFilter extends Comparable<BotFilter>
Interceptor interface for the bot update processing pipeline. Filters wrap around the handler dispatch, enabling cross-cutting concerns such as authentication, logging, and exception handling to be applied before and after the core handler chain runs. Filters are invoked in ascending getOrder() order and may delegate to the next element in the chain via the provided BotFilterChain.
Since:
0.0.1
Author:
Islom Mirsaburov
  • Method Summary

    Modifier and Type
    Method
    Description
    default int
    Compares this filter to another for ordering purposes.
    void
    doFilter(BotRequest botRequest, BotResponse botResponse, BotFilterChain filterChain)
    Performs filter logic and delegates to the next filter or handler in the chain.
    default int
    Returns the priority order of this filter.
    default boolean
    shouldFilter(BotRequest botRequest, BotResponse botResponse)
    Determines whether this filter should be applied for the current request.
  • Method Details

    • getOrder

      default int getOrder()
      Returns the priority order of this filter. Lower values indicate higher priority. Defaults to Integer.MAX_VALUE.
      Returns:
      the order value for this filter
    • doFilter

      void doFilter(BotRequest botRequest, BotResponse botResponse, BotFilterChain filterChain)
      Performs filter logic and delegates to the next filter or handler in the chain. Implementations should call filterChain.doFilter(botRequest, botResponse) to continue the pipeline.
      Parameters:
      botRequest - the current request context; must not be null
      botResponse - the mutable response object; must not be null
      filterChain - the remaining filter/handler chain to delegate to; must not be null
    • compareTo

      default int compareTo(BotFilter o)
      Compares this filter to another for ordering purposes.
      Specified by:
      compareTo in interface Comparable<BotFilter>
      Parameters:
      o - the other BotFilter to compare to; must not be null
      Returns:
      a negative integer, zero, or a positive integer as this filter's order is less than, equal to, or greater than the other filter's order
    • shouldFilter

      default boolean shouldFilter(BotRequest botRequest, BotResponse botResponse)
      Determines whether this filter should be applied for the current request. Return false to skip this filter entirely for the given request/response pair.
      Parameters:
      botRequest - the current request context; must not be null
      botResponse - the mutable response object; must not be null
      Returns:
      true if the filter should execute, false to skip it