Package com.vaadin.flow.router.internal
Class RouteUtil
java.lang.Object
com.vaadin.flow.router.internal.RouteUtil
Utility class with methods for route handling.
For internal use only. May be renamed or removed in a future release.
- Since:
- 1.3
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckForClientRouteCollisions(VaadinService service, String... flowRouteTemplates) Checks the given array of Flow route templates for potential collisions with Hilla routes.static voidcheckForClientRouteCollisions(VaadinService service, List<RouteData> flowRoutes) Checks the given list of Flow routes for potential collisions with Hilla routes.static List<Class<? extends RouterLayout>>collectRouteParentLayouts(Class<? extends RouterLayout> layout) Collects all parent layouts for a given route layout class.Search for a client route using given navigation url and return target template.getDynamicTitle(UI ui) Get optional dynamic page title from the active router targets chain of a given UI instance.static List<Class<? extends RouterLayout>>getParentLayouts(RouteRegistry handledRegistry, Class<?> component, String path) Get parent layouts for navigation target according to theRouteorRouteAliasannotation or automatically link RouterLayout annotated with theLayoutannotation matching route path.static List<Class<? extends RouterLayout>>getParentLayouts(VaadinContext context, Class<?> component, String path) Get parent layouts for navigation target according to theRouteorRouteAliasannotation.static List<Class<? extends RouterLayout>>getParentLayoutsForNonRouteTarget(Class<?> navigationTarget) Collect possible route parent layouts for a navigation target that is not annotated withRoutenorRouteAlias, but may still containParentLayout.static StringgetRouteAliasPath(Class<?> component, RouteAlias alias) Get the actual route path including all parent layoutRoutePrefix.static StringgetRoutePath(VaadinContext context, Class<?> component) Get the actual route path including all parent layoutRoutePrefix.static Class<? extends RouterLayout>getTopParentLayout(VaadinContext context, Class<?> component, String path) Get the top most parent layout for navigation target according to theRouteorRouteAliasannotation.static booleanhasAutoLayout(AbstractRouteRegistry registry) Check if the given registry has any auto layouts added with @Layoutannotation.static booleanhasClientRouteWithAutoLayout(AbstractConfiguration configuration) Check if currently registered client routes use auto layout based onAvailableViewInfo.flowLayout().static booleanCheck if the given registry has any routes using auto layout.static booleanisAutolayoutEnabled(Class<?> target, String path) Check if given route can get the automatic layout.static Stringresolve(VaadinContext context, Class<?> component) Gets the effective route path value of the annotated class.static voidupdateRouteRegistry(RouteRegistry registry, Set<Class<?>> addedClasses, Set<Class<?>> modifiedClasses, Set<Class<?>> deletedClasses) Updates route registry as necessary when classes have been added / modified / deleted.
-
Field Details
-
ROUTE_CONFLICT
- See Also:
-
ROUTE_CONFLICT_WITH_PARAMS
- See Also:
-
-
Constructor Details
-
RouteUtil
protected RouteUtil()
-
-
Method Details
-
getParentLayouts
public static List<Class<? extends RouterLayout>> getParentLayouts(VaadinContext context, Class<?> component, String path) Get parent layouts for navigation target according to theRouteorRouteAliasannotation.- Parameters:
context- a Vaadin contextcomponent- navigation target to get parents forpath- path used to get navigation target so we know which annotation to handle- Returns:
- parent layouts for target
-
getParentLayouts
public static List<Class<? extends RouterLayout>> getParentLayouts(RouteRegistry handledRegistry, Class<?> component, String path) Get parent layouts for navigation target according to theRouteorRouteAliasannotation or automatically link RouterLayout annotated with theLayoutannotation matching route path.- Parameters:
handledRegistry- current routeRegistrycomponent- navigation target to get parents forpath- path used to get navigation target so we know which annotation to handle- Returns:
- parent layouts for target
-
getRoutePath
Get the actual route path including all parent layoutRoutePrefix.- Parameters:
context- a Vaadin contextcomponent- navigation target component to get route path for- Returns:
- actual path for given route target
-
getRouteAliasPath
Get the actual route path including all parent layoutRoutePrefix.- Parameters:
component- navigation target component to get route path foralias- route alias annotation to check- Returns:
- actual path for given route alias target
-
collectRouteParentLayouts
public static List<Class<? extends RouterLayout>> collectRouteParentLayouts(Class<? extends RouterLayout> layout) Collects all parent layouts for a given route layout class.- Parameters:
layout- the layout class for which the parent layouts are collected.- Returns:
- a list of all parent layout classes starting from the given layout and including all ancestors in the hierarchy.
-
getParentLayoutsForNonRouteTarget
public static List<Class<? extends RouterLayout>> getParentLayoutsForNonRouteTarget(Class<?> navigationTarget) Collect possible route parent layouts for a navigation target that is not annotated withRoutenorRouteAlias, but may still containParentLayout. Mainly error navigation targets.- Parameters:
navigationTarget- route to check parent layouts for- Returns:
- list of parent layouts
-
getTopParentLayout
public static Class<? extends RouterLayout> getTopParentLayout(VaadinContext context, Class<?> component, String path) Get the top most parent layout for navigation target according to theRouteorRouteAliasannotation. Also handles non route targets withParentLayout.- Parameters:
component- navigation target to get top most parent forpath- path used to get navigation target so we know which annotation to handle or null for error views.- Returns:
- top parent layout for target or null if none found
-
resolve
Gets the effective route path value of the annotated class.- Parameters:
context- a Vaadin contextcomponent- the component where the route points to- Returns:
- The value of the annotation or naming convention based value if no explicit value is given.
-
updateRouteRegistry
public static void updateRouteRegistry(RouteRegistry registry, Set<Class<?>> addedClasses, Set<Class<?>> modifiedClasses, Set<Class<?>> deletedClasses) Updates route registry as necessary when classes have been added / modified / deleted.
Registry Update rules:- a route is preserved if the class does not have a
Routeannotation and did not have it at registration time - a route is preserved if the class is annotated with
RouteandregisterAtStartup=falseand the the flag has not changed - new classes are not automatically added to session registries
- existing routes in session registries are not removed in case of class modification
- Parameters:
registry- route registryaddedClasses- added classesmodifiedClasses- modified classesdeletedClasses- deleted classes
- a route is preserved if the class does not have a
-
isAutolayoutEnabled
Check if given route can get the automatic layout. Automatic layout can be used if it is aRoutewith noRoute.layout()set andRoute.autoLayout()as true.- Parameters:
target- target to check for accessibilitypath- path to determine if we are targeting aRouteAliasinstead ofRoute- Returns:
trueif auto layout can be used
-
checkForClientRouteCollisions
public static void checkForClientRouteCollisions(VaadinService service, List<RouteData> flowRoutes) throws InvalidRouteConfigurationException Checks the given list of Flow routes for potential collisions with Hilla routes. Note: Routes will only be checked in development mode, when Hilla is in use.- Parameters:
service- VaadinService instanceflowRoutes- Flow routes to check against- Throws:
InvalidRouteConfigurationException- if a collision is detected
-
checkForClientRouteCollisions
public static void checkForClientRouteCollisions(VaadinService service, String... flowRouteTemplates) throws InvalidRouteConfigurationException Checks the given array of Flow route templates for potential collisions with Hilla routes. Note: Routes will only be checked in development mode, when Hilla is in use.- Parameters:
service- VaadinService instanceflowRouteTemplates- Flow routes to check against- Throws:
InvalidRouteConfigurationException- if a collision is detected
-
hasAutoLayout
Check if the given registry has any auto layouts added with @Layoutannotation.- Parameters:
registry- the registry to check- Returns:
trueif the registry has any auto layouts
-
hasClientRouteWithAutoLayout
Check if currently registered client routes use auto layout based onAvailableViewInfo.flowLayout().- Parameters:
configuration- deployment configuration- Returns:
trueif any client route has auto layout
-
hasServerRouteWithAutoLayout
Check if the given registry has any routes using auto layout.- Parameters:
registry- the registry to check- Returns:
trueif the registry has any auto layouts
-
getDynamicTitle
Get optional dynamic page title from the active router targets chain of a given UI instance.- Parameters:
ui- instance of UI, notnull- Returns:
- dynamic page title found in the routes chain, or empty optional
if no implementor of
HasDynamicTitlewas found
-