Class RouteMatcher<R>

  • Type Parameters:
    R - The type of the request.
    Direct Known Subclasses:
    DelegatingRouteMatcher

    public abstract class RouteMatcher<R>
    extends Object
    A matcher for evaluating whether a route matches the incoming request. Implementing class can either return a RouteMatch, if the route matches, or null, if the route does not match, from the evaluate(Context, Object) method.

    Implementing classes must implement both equals(Object) and hashCode() methods as each instance of a RouteMatcher will be used as the key for a route.

    • Constructor Detail

      • RouteMatcher

        public RouteMatcher()
    • Method Detail

      • evaluate

        public abstract RouteMatch evaluate​(Context context,
                                            R request)
        Evaluates the request and determines whether it matches the route.
        Parameters:
        context - The request context.
        request - The request.
        Returns:
        A RouteMatch, if the request matches the route, or null, if not.
      • toString

        public abstract String toString()
        Returns a String representation of the route matcher.
        Overrides:
        toString in class Object
        Returns:
        A string representation of the route matcher.
      • idFragment

        public abstract String idFragment()
        The fragment of an API ID that this matcher provides.
        Returns:
        A fragment of the API ID.
      • hashCode

        public abstract int hashCode()
        Overrides:
        hashCode in class Object
      • equals

        public abstract boolean equals​(Object o)
        Overrides:
        equals in class Object
      • transformApi

        public abstract <D> D transformApi​(D descriptor,
                                           ApiProducer<D> producer)
        Transform the API Descriptor as appropriate for the parent router's view of the child routes.
        Type Parameters:
        D - The type of descriptor object.
        Parameters:
        descriptor - The descriptor to be mutated.
        producer - The API Descriptor producer.
        Returns:
        The new descriptor object.