Class UriTemplateMatcher

java.lang.Object
io.micronaut.http.uri.UriTemplateMatcher
All Implemented Interfaces:
UriMatcher, Comparable<UriTemplateMatcher>

@Internal public final class UriTemplateMatcher extends Object implements UriMatcher, Comparable<UriTemplateMatcher>
Implementation of the paths matching rfc6570.
Since:
4.6.0
Author:
Denis Stepanov
  • Constructor Details

    • UriTemplateMatcher

      public UriTemplateMatcher(String templateString)
      Construct a new URI template for the given template.
      Parameters:
      templateString - The template string
  • Method Details

    • match

      public Optional<UriMatchInfo> match(String uri)
      Match the given URI string.
      Specified by:
      match in interface UriMatcher
      Parameters:
      uri - The uRI
      Returns:
      an optional match
    • tryMatch

      public @Nullable UriMatchInfo tryMatch(@NonNull String uri)
      Match the given URI string.
      Parameters:
      uri - The uRI
      Returns:
      a match or null
    • nest

      public UriTemplateMatcher nest(CharSequence uriTemplate)
      Nests another URI template with this template.
      Parameters:
      uriTemplate - The URI template. If it does not begin with forward slash it will automatically be appended with forward slash
      Returns:
      The new URI template
    • toPathString

      public String toPathString()
      Returns the path string excluding any query variables.
      Returns:
      The path string
    • expand

      public String expand(Map<String,Object> parameters)
      Expand the string with the given parameters.
      Parameters:
      parameters - The parameters
      Returns:
      The expanded URI
    • compareTo

      public int compareTo(UriTemplateMatcher o)
      Specified by:
      compareTo in interface Comparable<UriTemplateMatcher>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • of

      public static UriTemplateMatcher of(String uri)
      /** Create a new UriTemplate for the given URI.
      Parameters:
      uri - The URI
      Returns:
      The template