com.vaadin.flow.router.internal.
Class 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 void
checkForClientRouteCollisions
(VaadinService service, String... flowRouteTemplates) Checks the given array of Flow route templates for potential collisions with Hilla routes.
static void
checkForClientRouteCollisions
(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 the
Route
orRouteAlias
annotation or automatically link RouterLayout annotated with theLayout
annotation matching route path.static List<Class<? extends RouterLayout>>
getParentLayouts
(VaadinContext context, Class<?> component, String path) Get parent layouts for navigation target according to the
Route
orRouteAlias
annotation.static List<Class<? extends RouterLayout>>
getParentLayoutsForNonRouteTarget
(Class<?> navigationTarget) Collect possible route parent layouts for a navigation target that is not annotated with
Route
norRouteAlias
, but may still containParentLayout
.static String
getRouteAliasPath
(Class<?> component, RouteAlias alias) Get the actual route path including all parent layout
RoutePrefix
.static String
getRoutePath
(VaadinContext context, Class<?> component) Get the actual route path including all parent layout
RoutePrefix
.static Class<? extends RouterLayout>
getTopParentLayout
(VaadinContext context, Class<?> component, String path) Get the top most parent layout for navigation target according to the
Route
orRouteAlias
annotation.static boolean
hasAutoLayout
(AbstractRouteRegistry registry) Check if the given registry has any auto layouts added with @
Layout
annotation.static boolean
hasClientRouteWithAutoLayout
(AbstractConfiguration configuration) Check if currently registered client routes use auto layout based on
AvailableViewInfo.flowLayout()
.static boolean
Check if the given registry has any routes using auto layout.
static boolean
isAutolayoutEnabled
(Class<?> target, String path) Check if given route can get the automatic layout.
static String
resolve
(VaadinContext context, Class<?> component) Gets the effective route path value of the annotated class.
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.
-
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 the
Route
orRouteAlias
annotation.Parameters:
context
- a Vaadin contextcomponent
- navigation target to get parents forpath
- path used to get navigation target so we know which annotation to handleReturns:
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 the
Route
orRouteAlias
annotation or automatically link RouterLayout annotated with theLayout
annotation 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 handleReturns:
parent layouts for target
-
getRoutePath
Get the actual route path including all parent layout
RoutePrefix
.Parameters:
context
- a Vaadin contextcomponent
- navigation target component to get route path forReturns:
actual path for given route target
-
getRouteAliasPath
Get the actual route path including all parent layout
RoutePrefix
.Parameters:
component
- navigation target component to get route path foralias
- route alias annotation to checkReturns:
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 with
Route
norRouteAlias
, but may still containParentLayout
. Mainly error navigation targets.Parameters:
navigationTarget
- route to check parent layouts forReturns:
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 the
Route
orRouteAlias
annotation. 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 toReturns:
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.
- a route is preserved if the class does not have a
Route
annotation and did not have it at registration time - a route is preserved if the class is annotated with
Route
andregisterAtStartup=false
and 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 a
Route
with noRoute.layout()
set andRoute.autoLayout()
as true.Parameters:
target
- target to check for accessibilitypath
- path to determine if we are targeting aRouteAlias
instead ofRoute
Returns:
true
if 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 againstThrows:
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 againstThrows:
InvalidRouteConfigurationException
- if a collision is detected -
hasAutoLayout
Check if the given registry has any auto layouts added with @
Layout
annotation.Parameters:
registry
- the registry to checkReturns:
true
if the registry has any auto layouts -
hasClientRouteWithAutoLayout
Check if currently registered client routes use auto layout based on
AvailableViewInfo.flowLayout()
.Parameters:
configuration
- deployment configurationReturns:
true
if any client route has auto layout -
hasServerRouteWithAutoLayout
Check if the given registry has any routes using auto layout.
Parameters:
registry
- the registry to checkReturns:
true
if 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
HasDynamicTitle
was found
-