Class AbstractRouteManager<A,B,C extends AbstractRoute<A,B,C,D,E,F>,D extends AbstractRouteManager<A,B,C,D,E,F>,E extends AbstractRouter<A,B,C,D,E,F>,F extends AbstractRouteExtractor<A,B,C,D,E,F>>

java.lang.Object
io.inverno.mod.http.base.router.AbstractRouteManager<A,B,C,D,E,F>
Type Parameters:
A - the resource type
B - the input type
C - the route type
D - the route manager type
E - the router type
F - the route extractor type
All Implemented Interfaces:
RouteManager<A,B,C,D,E>

public abstract class AbstractRouteManager<A,B,C extends AbstractRoute<A,B,C,D,E,F>,D extends AbstractRouteManager<A,B,C,D,E,F>,E extends AbstractRouter<A,B,C,D,E,F>,F extends AbstractRouteExtractor<A,B,C,D,E,F>> extends Object implements RouteManager<A,B,C,D,E>

Base RouteManager implementation.

Since:
1.12
Author:
Jeremy Kuhn
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates a route manager.
  • Method Summary

    Modifier and Type
    Method
    Description
    final E
    Disables all routes matching the criteria specified in the route manager and defined in the router it comes from.
    final E
    Enables all routes matching the criteria specified in the route manager and defined in the router it comes from.
    final Set<C>
    Finds all routes matching the criteria specified in the route manager and defined in the router it comes from.
    final E
    Removes all routes matching the criteria specified in the route manager and defined in the router it comes from.
    protected abstract Function<Consumer<F>,Consumer<F>>
    Returns the route extractor function.
    protected abstract Predicate<C>
    Returns the route matcher.
    set(Supplier<A> resourceFactory, Consumer<C> routeConfigurer)
    Sets the routes in the router targeting resources provided by the specified factory, configure the resulting routes with the specified configurer and returns the router.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.inverno.mod.http.base.router.RouteManager

    set, set
  • Constructor Details

    • AbstractRouteManager

      protected AbstractRouteManager(E router)

      Creates a route manager.

      Parameters:
      router - the router
  • Method Details

    • routeMatcher

      protected abstract Predicate<C> routeMatcher()

      Returns the route matcher.

      The route matcher is used to determine whether a route is matching the criteria defined in the route manager.

      Returns:
      a route matcher
      See Also:
    • routeExtractor

      protected abstract Function<Consumer<F>,Consumer<F>> routeExtractor()

      Returns the route extractor function.

      The route extractor is used to extract routes from the route manager when the resource is set. Relying on a Function allows to easily chain and combine extractor specific to a criteria.

      Returns:
      a route extractor function
    • set

      public E set(Supplier<A> resourceFactory, Consumer<C> routeConfigurer)
      Description copied from interface: RouteManager

      Sets the routes in the router targeting resources provided by the specified factory, configure the resulting routes with the specified configurer and returns the router.

      Unlike RouteManager.set(Object), each resulting routes target a different resource instance provided by the specified resource factory.

      The route configurer allows to post process the route before adding it to the server. This especially allows to set specific route information into the resource instance.

      Specified by:
      set in interface RouteManager<A,B,C extends AbstractRoute<A,B,C,D,E,F>,D extends AbstractRouteManager<A,B,C,D,E,F>,E extends AbstractRouter<A,B,C,D,E,F>>
      Parameters:
      resourceFactory - a resource factory
      routeConfigurer - a route configurer
      Returns:
      the router
    • enable

      public final E enable()
      Description copied from interface: RouteManager

      Enables all routes matching the criteria specified in the route manager and defined in the router it comes from.

      Specified by:
      enable in interface RouteManager<A,B,C extends AbstractRoute<A,B,C,D,E,F>,D extends AbstractRouteManager<A,B,C,D,E,F>,E extends AbstractRouter<A,B,C,D,E,F>>
      Returns:
      the router
    • disable

      public final E disable()
      Description copied from interface: RouteManager

      Disables all routes matching the criteria specified in the route manager and defined in the router it comes from.

      Specified by:
      disable in interface RouteManager<A,B,C extends AbstractRoute<A,B,C,D,E,F>,D extends AbstractRouteManager<A,B,C,D,E,F>,E extends AbstractRouter<A,B,C,D,E,F>>
      Returns:
      the router
    • remove

      public final E remove()
      Description copied from interface: RouteManager

      Removes all routes matching the criteria specified in the route manager and defined in the router it comes from.

      Specified by:
      remove in interface RouteManager<A,B,C extends AbstractRoute<A,B,C,D,E,F>,D extends AbstractRouteManager<A,B,C,D,E,F>,E extends AbstractRouter<A,B,C,D,E,F>>
      Returns:
      the router
    • findRoutes

      public final Set<C> findRoutes()
      Description copied from interface: RouteManager

      Finds all routes matching the criteria specified in the route manager and defined in the router it comes from.

      Specified by:
      findRoutes in interface RouteManager<A,B,C extends AbstractRoute<A,B,C,D,E,F>,D extends AbstractRouteManager<A,B,C,D,E,F>,E extends AbstractRouter<A,B,C,D,E,F>>
      Returns:
      a set of routes or an empty set if no route matches the criteria