Class RouteHierarchy
@Route
annotated class.
At each step, the walker first consults @RouteParent: if
the annotation is present, its target is itself @Route-annotated and
has not yet been visited, that target becomes the parent. Otherwise the
walker falls back to URL-prefix walking: it takes the current class's route
template via RouteConfiguration.getTemplate(Class), strips the last
/-separated segment, and looks up the resulting path in the supplied
RouteConfiguration. Traversal terminates when no parent can be
resolved, when a candidate would form a cycle, or when the current template
has no further segments to strip.
Cycles in the hierarchy are detected via a visited set and truncated rather than reported as errors. The resulting chain is therefore always finite and free of duplicates.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionresolveAncestors(Class<? extends Component> routeClass, RouteConfiguration routeConfiguration) Returns the chain of route classes from the conceptual root down to and includingrouteClass.resolveParent(Class<? extends Component> routeClass, RouteConfiguration routeConfiguration) Returns the immediate parent ofrouteClass, or an emptyOptionalwhen no parent can be resolved.
-
Method Details
-
resolveAncestors
public static List<Class<? extends Component>> resolveAncestors(Class<? extends Component> routeClass, RouteConfiguration routeConfiguration) Returns the chain of route classes from the conceptual root down to and includingrouteClass.The returned list is root-first: the root ancestor comes first and
routeClassis always the last element. WhenrouteClassis not annotated with@Route, an empty list is returned. WhenrouteClassis a@Routeview but no parent can be resolved, the returned list contains onlyrouteClassitself.The walk consults
@RouteParentfirst at each step and falls back to URL-prefix walking viaRouteConfiguration.getTemplate(Class)andRouteConfiguration.getRoute(String). Cycles are truncated.- Parameters:
routeClass- the route class to start from, notnullrouteConfiguration- the route configuration used to resolve templates and ancestor routes, notnull- Returns:
- root-first list of ancestor route classes inclusive of
routeClass, or an empty list whenrouteClassis not annotated with@Route - See Also:
-
resolveParent
public static Optional<Class<? extends Component>> resolveParent(Class<? extends Component> routeClass, RouteConfiguration routeConfiguration) Returns the immediate parent ofrouteClass, or an emptyOptionalwhen no parent can be resolved.This is equivalent to taking the second-to-last entry of
resolveAncestors(Class, RouteConfiguration)for chains of length two or more, and empty otherwise.@RouteParentis consulted first; URL-prefix walking is the fallback.- Parameters:
routeClass- the route class to find the parent of, notnullrouteConfiguration- the route configuration used to resolve templates and ancestor routes, notnull- Returns:
- an
Optionaldescribing the parent route class, orOptional.empty()whenrouteClasshas no@Routeannotation or no parent can be resolved - See Also:
-