Class ApiPathImpl

java.lang.Object
com.atlassian.oai.validator.model.NormalisedPathImpl
com.atlassian.oai.validator.model.ApiPathImpl
All Implemented Interfaces:
ApiPath, NormalisedPath

public class ApiPathImpl extends NormalisedPathImpl implements ApiPath
  • Constructor Details

    • ApiPathImpl

      public ApiPathImpl(@Nonnull String path, @Nullable String apiPrefix)
    • ApiPathImpl

      public ApiPathImpl(@Nonnull String path, @Nullable String apiPrefix, boolean strictPathMatching)
      Parameters:
      strictPathMatching - If true, a trailing slash indicates a different path than without.
  • Method Details

    • matches

      public boolean matches(NormalisedPath requestPath)
      Description copied from interface: ApiPath
      Determine if the given request path matches this API path, taking into consideration path params.

      Note that this method does not validate path params in the incoming request path part - it merely indicates that it matches the template described in the API path expression.

      Specified by:
      matches in interface ApiPath
      Parameters:
      requestPath - The request path to test
      Returns:
      true if the incoming request path matches against the template defined in this API path; false otherwise.
    • partMatches

      public boolean partMatches(int index, @Nonnull String requestPathPart)
      Description copied from interface: ApiPath
      Determine if the given request path part matches against the corresponding path part in this API path, taking into consideration path params.

      Note that this method does not validate path params in the incoming request path part - it merely indicates that it matches the template described in the API path expression.

      Specified by:
      partMatches in interface ApiPath
      Parameters:
      index - The path part index to compare
      requestPathPart - The request path part to match
      Returns:
      true if the incoming request path part matches against the template defined in this API path; false otherwise.
    • hasParams

      public boolean hasParams(int index)
      Specified by:
      hasParams in interface ApiPath
      Returns:
      Whether the path part at the given index contains one or more path params (e.g. "/my/{param}/")
    • paramNames

      public List<String> paramNames(int index)
      Specified by:
      paramNames in interface ApiPath
      Returns:
      The parameter name(s) in the path part at the given index, or an empty list if the given part does not have a parameter. Parameter names are returned in order.
    • paramValues

      public Map<String,Optional<String>> paramValues(int index, String requestPathPart)
      Description copied from interface: ApiPath
      Extract the param values for each param in the indexed path part, extracted from the given request path part.
      Specified by:
      paramValues in interface ApiPath
      Parameters:
      index - The index of the path part to extract templated params with
      requestPathPart - The request path part to extract param values from
      Returns:
      The (name, value) for each path param in the given part. If the param could not be found, will be empty.