Package com.duncpro.jroute.router
Class TreeRouter<E>
- java.lang.Object
-
- com.duncpro.jroute.router.TreeRouter<E>
-
-
Constructor Summary
Constructors Constructor Description TreeRouter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Route route, E endpoint)protected static <E> java.util.Optional<com.duncpro.jroute.router.RouteTreeNode<E>>findNode(com.duncpro.jroute.router.RouteTreeNode<E> routeTree, Path path)Finds theRouteTreeNodewhich is responsible for handling requests made on the givenPath.protected static <E> com.duncpro.jroute.router.RouteTreeNode<E>findOrCreateNode(com.duncpro.jroute.router.RouteTreeNode<E> routeTree, Route route)A variant offindNode(RouteTreeNode, Path)which will add new branches to the route tree if necessary so that theRoutemay be resolved to aRouteTreeNode.java.util.Set<PositionedEndpoint<E>>getAllEndpoints(Route prefix)Returns a set ofPositionedEndpoints which are accessible via the givenRoute.java.util.Optional<E>getEndpoint(Route at)Returns the endpoint which exists at the givenRoute(if any).EgetOrAdd(Route route, java.util.function.Supplier<E> endpointFactory)java.util.Optional<RouteMatch<E>>route(Path path)
-
-
-
Method Detail
-
route
public java.util.Optional<RouteMatch<E>> route(Path path)
-
add
public void add(Route route, E endpoint) throws RouteConflictException
- Specified by:
addin interfaceRouter<E>- Throws:
RouteConflictException
-
getAllEndpoints
public java.util.Set<PositionedEndpoint<E>> getAllEndpoints(Route prefix)
Description copied from interface:RouterReturns a set ofPositionedEndpoints which are accessible via the givenRoute. The returned collection includes the endpoints defined on the givenRouteas well as all endpoints which exists on routes that descend from the givenRoute.- Specified by:
getAllEndpointsin interfaceRouter<E>
-
getEndpoint
public java.util.Optional<E> getEndpoint(Route at)
Description copied from interface:RouterReturns the endpoint which exists at the givenRoute(if any).- Specified by:
getEndpointin interfaceRouter<E>
-
findNode
protected static <E> java.util.Optional<com.duncpro.jroute.router.RouteTreeNode<E>> findNode(com.duncpro.jroute.router.RouteTreeNode<E> routeTree, Path path)Finds theRouteTreeNodewhich is responsible for handling requests made on the givenPath. If noRouteTreeNodehas been delegated for this path, any empty optional is returned instead.
-
findOrCreateNode
protected static <E> com.duncpro.jroute.router.RouteTreeNode<E> findOrCreateNode(com.duncpro.jroute.router.RouteTreeNode<E> routeTree, Route route)A variant offindNode(RouteTreeNode, Path)which will add new branches to the route tree if necessary so that theRoutemay be resolved to aRouteTreeNode. If no nodes need to be added then this function is analogous to the aforementioned one. Finally this function returns theRouteTreeNodecorresponding to the lastRouteElementin theRoute.
-
-