Class ConfiguredRoutes

java.lang.Object
com.vaadin.flow.router.internal.ConfiguredRoutes
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ConfigureRoutes

public class ConfiguredRoutes extends Object implements Serializable
Route configuration class that is used as a value object.

Note! This is always immutable and any changes should be made from ConfigureRoutes.

For internal use only. May be renamed or removed in a future release.

Since:
1.3
See Also:
  • Constructor Details

    • ConfiguredRoutes

      public ConfiguredRoutes()
      Create an immutable RouteConfiguration.
    • ConfiguredRoutes

      public ConfiguredRoutes(ConfigureRoutes original)
      Create a mutable or immutable configuration with original configuration information.
      Parameters:
      original - original configuration to get data from
  • Method Details

    • getRoutesMap

      protected Map<String,RouteTarget> getRoutesMap()
    • getRoutePaths

      protected List<String> getRoutePaths(Class<? extends Component> routeTarget)
      Collect all routes for which given routeTarget is registered. This is mainly for handling route aliases as reading from the class annotations doesn't specifically return the actual registrations as they can change during runtime.
      Parameters:
      routeTarget - route target to collect registered paths for
      Returns:
      list of routes this routeTarget is registered for
    • hasRoute

      public boolean hasRoute(String path)
      See if configuration contains a registered route for given path.
      Parameters:
      path - path to check
      Returns:
      true if configuration contains route
    • hasTemplate

      public boolean hasTemplate(String template)
      See if configuration contains a registered route for given template.
      Parameters:
      template - template to check
      Returns:
      true if configuration contains route
    • hasRoute

      public boolean hasRoute(String path, List<String> segments)
      Check if configuration holds a route for given path with possible path segments.
      Parameters:
      path - path string to check
      segments - path segments for route
      Returns:
      true if a route is found, else false
    • hasRouteTarget

      public boolean hasRouteTarget(Class<? extends Component> target)
      Check it the given route target has been registered to the configuration.
      Parameters:
      target - target to check registration status for
      Returns:
      true if target is found in configuration
    • getNavigationRouteTarget

      public NavigationRouteTarget getNavigationRouteTarget(String url)
      Search for a route target using given navigation url argument.
      Parameters:
      url - the navigation url used to search a route target.
      Returns:
      a NavigationRouteTarget instance containing the RouteTarget and RouteParameters extracted from the url argument according with the route configuration.
    • getRouteTarget

      public RouteTarget getRouteTarget(Class<? extends Component> target, RouteParameters parameters)
      Gets the RouteTarget instance matching the given target component and route parameters.
      Parameters:
      target - a component class which is a navigation target.
      parameters - parameter values that may be used with given target.
      Returns:
      the RouteTarget instance matching the given target component and route parameters.
    • getTarget

      public Optional<Class<? extends Component>> getTarget(String url)
      Get the target class matching the given url.
      Parameters:
      url - string to get the route for
      Returns:
      Optional containing the navigationTarget class if found
    • getRoute

      public Optional<Class<? extends Component>> getRoute(String url, List<String> segments)
      Get the route class matching the given path and path segments.
      Parameters:
      url - string to get the route for
      segments - possible path segments
      Returns:
      Optional containing the navigationTarget class if found
    • getRoutes

      public Set<String> getRoutes()
      Get all registered paths that have been registered.
      Returns:
      Set containing all the registered paths
    • getTargetRoutes

      public Map<Class<? extends Component>,String> getTargetRoutes()
      Get all registered target routes for this configuration mapping the main template.
      Returns:
      component-to-path map of all target routes
    • copyTargetRouteModels

      protected final Map<Class<? extends Component>,com.vaadin.flow.router.internal.RouteModel> copyTargetRouteModels(boolean mutable)
      Make a copy of the target and route models mapping.
      Returns:
      a copy of the target and route models mapping.
    • getTargetRoute

      public String getTargetRoute(Class<? extends Component> navigationTarget)
      Get the route template String for the given navigation target class.
      Parameters:
      navigationTarget - navigationTarget to get registered route for
      Returns:
      base route string if target class found
    • getTemplate

      public String getTemplate(Class<? extends Component> navigationTarget)
      Get the route template String for the given navigation target class.
      Parameters:
      navigationTarget - navigationTarget to get registered route for
      Returns:
      base route string if target class found
    • getTemplate

      public String getTemplate(Class<? extends Component> navigationTarget, Set<RouteParameterFormatOption> format)
      Get the route template String for the given navigation target class and using the specified parameters format.
      Parameters:
      navigationTarget - navigationTarget to get registered route for
      format - settings used to format the result parameters. If all of RouteParameterFormatOption.NAME, RouteParameterFormatOption.MODIFIER and RouteParameterFormatOption.REGEX are provided, the unformatted template will be provided.
      Returns:
      base route string if target class found
    • getTargetUrl

      public String getTargetUrl(Class<? extends Component> navigationTarget)
      Get the url path String for the given navigation target class.
      Parameters:
      navigationTarget - navigationTarget to get registered route for
      Returns:
      route string if target class found
    • getTargetUrl

      public String getTargetUrl(Class<? extends Component> navigationTarget, RouteParameters parameters)
      Get the url path String for the given navigation target class and parameters.
      Parameters:
      navigationTarget - navigationTarget to get registered route for
      parameters - route parameters
      Returns:
      url String populated with parameters for the given navigationTarget
    • getExceptionHandlerByClass

      public Class<? extends Component> getExceptionHandlerByClass(Class<?> exceptionClass)
      Get a exception handler by exception class.
      Parameters:
      exceptionClass - exception class to get exception handler for
      Returns:
      exception handler if found
    • getExceptionHandlers

      public Map<Class<? extends Exception>,Class<? extends Component>> getExceptionHandlers()
      Get all registered exception handlers as a exception-to-handler map.
      Returns:
      all registered exception handlers
    • getParameters

      public Map<String,RouteParameterData> getParameters(String template)
      Gets the parameters defined by the given template.
      Parameters:
      template - template to get parameters from.
      Returns:
      map parameter names with RouteParameterData.
    • getRouteTarget

      protected RouteTarget getRouteTarget(String template)
      Get the RouteTarget stored for the given template.
      Parameters:
      template - template to get route target for
      Returns:
      route target for template, null if nothing registered