Class PathTemplates

java.lang.Object
com.arc_e_tect.gradle.shadow.model.PathTemplates

public final class PathTemplates extends Object
Utility methods for normalising and combining Spring MVC / OpenAPI path templates so that they can be compared regardless of superficial formatting differences.
  • Method Details

    • join

      public static String join(String base, String sub)
      Joins a base path and a sub-path into a single normalised path template.
      Parameters:
      base - the base path, e.g. a class-level @RequestMapping value; may be blank
      sub - the sub-path, e.g. a method-level mapping value; may be blank
      Returns:
      the combined, normalised path, always starting with "/"
    • normalize

      public static String normalize(String path)
      Normalises a path template: ensures a leading "/", collapses repeated "/" separators, strips path-variable regex constraints (e.g. "{id:[0-9]+}" becomes "{id}"), and removes a trailing "/" (other than for the root path "/" itself).
      Parameters:
      path - the raw path template
      Returns:
      the normalised path template
    • isPlaceholder

      public static boolean isPlaceholder(String segment)
      Returns whether segment is a Spring/OpenAPI path-variable placeholder, i.e. wrapped in curly braces, e.g. "{id}".
      Parameters:
      segment - a single, "/"-delimited path segment
      Returns:
      true when segment is a placeholder segment