@Experimental public class RouteMatcher extends Object
DiscordRequest. You can create instances of this class using the
route(Route) factory, or through any() to provide a catch-all matcher.| Constructor and Description |
|---|
RouteMatcher(DiscordRequest<?> request,
Predicate<Map<String,String>> requestVariableMatcher) |
| Modifier and Type | Method and Description |
|---|---|
static RouteMatcher |
any()
Create a new
RouteMatcher that returns true for every request. |
boolean |
matches(DiscordRequest<?> otherRequest)
Tests this matcher against the given
DiscordRequest. |
static RouteMatcher |
route(Route<?> route)
Create a new
RouteMatcher that matches any request made for the given Route. |
static RouteMatcher |
route(Route<?> route,
Predicate<Map<String,String>> requestVariableMatcher)
Create a new
RouteMatcher that matches every request made for the given Route that also match
a given Predicate of URI variables. |
public RouteMatcher(DiscordRequest<?> request, Predicate<Map<String,String>> requestVariableMatcher)
public static RouteMatcher any()
RouteMatcher that returns true for every request.RouteMatcherpublic static RouteMatcher route(Route<?> route)
RouteMatcher that matches any request made for the given Route. A list of
Route objects exist in the Routes class.route - the Route to be matched by this instanceRouteMatcherpublic static RouteMatcher route(Route<?> route, Predicate<Map<String,String>> requestVariableMatcher)
RouteMatcher that matches every request made for the given Route that also match
a given Predicate of URI variables.
The given predicate will receive a Map of String URI template parameters as keys and String values used to compile the URI for a DiscordRequest. This means you would expect keys as
guild.id, channel.id, message.id, user.id, among others. Refer to the actual
Route instances declared in the Routes class for the exact template keys used in the requests
you want to match.
route - the Route to be matched by this instancerequestVariableMatcher - a Map of String keys and values representing the URI template and
the completed value for a given DiscordRequest, respectivelyRouteMatcherpublic boolean matches(DiscordRequest<?> otherRequest)
DiscordRequest.otherRequest - the DiscordRequest argumenttrue if the input argument matches the predicate, otherwise false