Interface BotFilter
- All Superinterfaces:
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 TypeMethodDescriptiondefault intCompares this filter to another for ordering purposes.voiddoFilter(BotRequest botRequest, BotResponse botResponse, BotFilterChain filterChain) Performs filter logic and delegates to the next filter or handler in the chain.default intgetOrder()Returns the priority order of this filter.default booleanshouldFilter(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 toInteger.MAX_VALUE.- Returns:
- the order value for this filter
-
doFilter
Performs filter logic and delegates to the next filter or handler in the chain. Implementations should callfilterChain.doFilter(botRequest, botResponse)to continue the pipeline.- Parameters:
botRequest- the current request context; must not benullbotResponse- the mutable response object; must not benullfilterChain- the remaining filter/handler chain to delegate to; must not benull
-
compareTo
Compares this filter to another for ordering purposes.- Specified by:
compareToin interfaceComparable<BotFilter>- Parameters:
o- the otherBotFilterto compare to; must not benull- 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
Determines whether this filter should be applied for the current request. Returnfalseto skip this filter entirely for the given request/response pair.- Parameters:
botRequest- the current request context; must not benullbotResponse- the mutable response object; must not benull- Returns:
trueif the filter should execute,falseto skip it
-