Interface Router<A,B,C extends Route<A>,D extends RouteManager<A,B,C,D,E>,E extends Router<A,B,C,D,E>>

Type Parameters:
A - the resource type
B - the router input type
C - the route type
D - the route manager type
E - the router type
All Known Implementing Classes:
AbstractRouter

public interface Router<A,B,C extends Route<A>,D extends RouteManager<A,B,C,D,E>,E extends Router<A,B,C,D,E>>

A router resolves the best matching resource for a specific input.

In order to match a resource, a router uses route definitions that provides the target resource and the criteria used to match the input. A Route is defined on the router using a RouteManager obtained from route().

Since:
1.12
Author:
Jeremy Kuhn
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the routes defined in the router.
    resolve(B input)
    Resolves the resource best matching the specified input.
    resolveAll(B input)
    Resolves all resources matching the specified input ordered from the best matching to the least matching.
    Returns a new route manager to define a route in the router.
    route(Consumer<D> configurer)
    Defines a route in the router using a configurer.
  • Method Details

    • route

      D route()

      Returns a new route manager to define a route in the router.

      Returns:
      a new route manager
    • route

      E route(Consumer<D> configurer)

      Defines a route in the router using a configurer.

      Parameters:
      configurer - a route configurer
      Returns:
      the router
    • getRoutes

      Set<C> getRoutes()

      Returns the routes defined in the router.

      Returns:
      a set of routes
    • resolve

      A resolve(B input)

      Resolves the resource best matching the specified input.

      Parameters:
      input - an input
      Returns:
      the best matching resource or null if the input is not matching any route
    • resolveAll

      Collection<A> resolveAll(B input)

      Resolves all resources matching the specified input ordered from the best matching to the least matching.

      Parameters:
      input - an input
      Returns:
      a list of resources ordered from the best matching to the least matching or an empty if no route is matching the input