org.springframework.util

## Class SimpleRouteMatcher

- java.lang.Object
- - org.springframework.util.SimpleRouteMatcher

- All Implemented Interfaces:
    RouteMatcher

      public class SimpleRouteMatcher
      extends Object
      implements RouteMatcher

  `RouteMatcher` that delegates to a `PathMatcher`.

  Note: This implementation is not efficient since `PathMatcher` treats paths and patterns as Strings. For more optimized performance use the `PathPatternRouteMatcher` from `spring-web` which enables use of parsed routes and patterns.

  Since:
    5.2
  Author:
    Rossen Stoyanchev

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.springframework.util.RouteMatcher

      `RouteMatcher.Route`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleRouteMatcher(PathMatcher pathMatcher)` Create a new `SimpleRouteMatcher` for the given `PathMatcher` delegate.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `combine(String pattern1, String pattern2)` Combines two patterns into a single pattern.
    `PathMatcher` | `getPathMatcher()` Return the underlying `PathMatcher` delegate.
    `Comparator<String>` | `getPatternComparator(RouteMatcher.Route route)` Given a route, return a `Comparator` suitable for sorting patterns in order of explicitness for that route, so that more specific patterns come before more generic ones.
    `boolean` | `isPattern(String route)` Whether the given `route` contains pattern syntax which requires the `RouteMatcher.match(String, Route)` method, or if it is a regular String that could be compared directly to others.
    `boolean` | `match(String pattern, RouteMatcher.Route route)` Match the given route against the given pattern.
    `Map<String,String>` | `matchAndExtract(String pattern, RouteMatcher.Route route)` Match the pattern to the route and extract template variables.
    `RouteMatcher.Route` | `parseRoute(String route)` Return a parsed representation of the given route.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SimpleRouteMatcher

          public SimpleRouteMatcher(PathMatcher pathMatcher)

      Create a new `SimpleRouteMatcher` for the given `PathMatcher` delegate.

  - ### Method Detail

    - #### getPathMatcher

          public PathMatcher getPathMatcher()

      Return the underlying `PathMatcher` delegate.

    - #### parseRoute

          public RouteMatcher.Route parseRoute(String route)

      Description copied from interface: `RouteMatcher`
      Return a parsed representation of the given route.
      Specified by:
        `parseRoute` in interface `RouteMatcher`
      Parameters:
        `route` - the route to parse
      Returns:
        the parsed representation of the route

    - #### isPattern

          public boolean isPattern(String route)

      Description copied from interface: `RouteMatcher`
      Whether the given `route` contains pattern syntax which requires the `RouteMatcher.match(String, Route)` method, or if it is a regular String that could be compared directly to others.
      Specified by:
        `isPattern` in interface `RouteMatcher`
      Parameters:
        `route` - the route to check
      Returns:
        `true` if the given `route` represents a pattern

    - #### combine

          public String combine(String pattern1,
                                String pattern2)

      Description copied from interface: `RouteMatcher`
      Combines two patterns into a single pattern.
      Specified by:
        `combine` in interface `RouteMatcher`
      Parameters:
        `pattern1` - the first pattern
        `pattern2` - the second pattern
      Returns:
        the combination of the two patterns

    - #### match

          public boolean match(String pattern,
                               RouteMatcher.Route route)

      Description copied from interface: `RouteMatcher`
      Match the given route against the given pattern.
      Specified by:
        `match` in interface `RouteMatcher`
      Parameters:
        `pattern` - the pattern to try to match
        `route` - the route to test against
      Returns:
        `true` if there is a match, `false` otherwise

    - #### matchAndExtract

          @Nullable
          public Map<String,String> matchAndExtract(String pattern,
                                                              RouteMatcher.Route route)

      Description copied from interface: `RouteMatcher`
      Match the pattern to the route and extract template variables.
      Specified by:
        `matchAndExtract` in interface `RouteMatcher`
      Parameters:
        `pattern` - the pattern, possibly containing templates variables
        `route` - the route to extract template variables from
      Returns:
        a map with template variables and values

    - #### getPatternComparator

          public Comparator<String> getPatternComparator(RouteMatcher.Route route)

      Description copied from interface: `RouteMatcher`
      Given a route, return a `Comparator` suitable for sorting patterns in order of explicitness for that route, so that more specific patterns come before more generic ones.
      Specified by:
        `getPatternComparator` in interface `RouteMatcher`
      Parameters:
        `route` - the full path to use for comparison
      Returns:
        a comparator capable of sorting patterns in order of explicitness