Class UrlPathMatcher

java.lang.Object
org.apache.juneau.rest.util.UrlPathMatcher
All Implemented Interfaces:
Comparable<UrlPathMatcher>

public abstract class UrlPathMatcher extends Object implements Comparable<UrlPathMatcher>
A parsed path pattern constructed from a @RestOp(path) value.

Handles aspects of matching and precedence ordering.

See Also:
  • Method Details

    • of

      public static UrlPathMatcher of(String pattern)
      Constructs a matcher from the specified pattern string.
      Parameters:
      pattern - The pattern string.
      Returns:
      A new matcher.
    • match

      public abstract UrlPathMatch match(UrlPath pathInfo)
      Returns a non-null value if the specified path matches this pattern.
      Parameters:
      pathInfo - The path to match against.
      Returns:
      A pattern match object, or null if the path didn't match this pattern.
    • getComparator

      protected abstract String getComparator()
      Returns a string that can be used to compare this matcher with other matchers to provide the ability to order URL patterns from most-specific to least-specific.
      Returns:
      A comparison string.
    • getVars

      public String[] getVars()
      Returns the variable names found in the pattern.
      Returns:
      The variable names or an empty array if no variables found.
      Modifying the returned array does not modify this object.
    • hasVars

      public boolean hasVars()
      Returns true if this path pattern contains variables.
      Returns:
      true if this path pattern contains variables.
    • compareTo

      public int compareTo(UrlPathMatcher o)
      Comparator for this object.

      The comparator is designed to order URL pattern from most-specific to least-specific. For example, the following patterns would be ordered as follows:

      1. foo.bar
      2. *.bar
      3. /foo/bar
      4. /foo/bar/*
      5. /foo/{id}/bar
      6. /foo/{id}/bar/*
      7. /foo/{id}
      8. /foo/{id}/*
      9. /foo
      10. /foo/*
      Specified by:
      compareTo in interface Comparable<UrlPathMatcher>
    • toString

      public String toString()
      Overrides:
      toString in class Object