Package discord4j.rest.request
Class RouteMatcher
java.lang.Object
discord4j.rest.request.RouteMatcher
A predicate that can match a given
DiscordWebRequest. You can create instances of this class using the
route(Route) factory, or through any() to provide a catch-all matcher.-
Constructor Summary
ConstructorsConstructorDescriptionRouteMatcher(DiscordWebRequest request, Predicate<Map<String, String>> requestVariableMatcher) -
Method Summary
Modifier and TypeMethodDescriptionstatic RouteMatcherany()Create a newRouteMatcherthat returns true for every request.booleanmatches(DiscordWebRequest otherRequest) Tests this matcher against the givenDiscordWebRequest.static RouteMatcherCreate a newRouteMatcherthat matches any request made for the givenRoute.static RouteMatcherCreate a newRouteMatcherthat matches every request made for the givenRoutethat also match a givenPredicateof URI variables.
-
Constructor Details
-
RouteMatcher
-
-
Method Details
-
any
Create a newRouteMatcherthat returns true for every request.- Returns:
- a new
RouteMatcher
-
route
Create a newRouteMatcherthat matches any request made for the givenRoute. A list ofRouteobjects exist in theRoutesclass.- Parameters:
route- theRouteto be matched by this instance- Returns:
- a new
RouteMatcher
-
route
Create a newRouteMatcherthat matches every request made for the givenRoutethat also match a givenPredicateof URI variables.The given predicate will receive a
MapofStringURI template parameters as keys andStringvalues used to compile the URI for aDiscordWebRequest. This means you would expect keys asguild.id,channel.id,message.id,user.id, among others. Refer to the actualRouteinstances declared in theRoutesclass for the exact template keys used in the requests you want to match.- Parameters:
route- theRouteto be matched by this instancerequestVariableMatcher- aMapofStringkeys and values representing the URI template and the completed value for a givenDiscordWebRequest, respectively- Returns:
- a new
RouteMatcher
-
matches
Tests this matcher against the givenDiscordWebRequest.- Parameters:
otherRequest- theDiscordWebRequestargument- Returns:
trueif the input argument matches the predicate, otherwisefalse
-