Class PathGenerator

java.lang.Object
org.apache.sling.resourceresolver.impl.mapping.PathGenerator

public class PathGenerator extends Object
Utility to generate all possible paths from segments (names)

This class expects to be supplied segments starting with the top-most ones (leaves) up until, but excluding, the root.

It generates all possible path combinations using a cartesian product that accummulates using a StringBuilder instead of a set, to prevent intermediate object creation.

  • Constructor Details

    • PathGenerator

      public PathGenerator()
  • Method Details

    • insertSegment

      public void insertSegment(@NotNull @NotNull Collection<String> alias, @NotNull @NotNull String name)
      Inserts a new segment as the parent of the existing ones
      Parameters:
      alias - the list of aliases
      name - the name
    • setResolutionPathInfo

      public void setResolutionPathInfo(@Nullable @Nullable String resolutionInfo)
      Sets the resolution info, to be appended at the end
      Parameters:
      resolutionInfo - the resolution info to append, ignored if null or empty
    • generatePaths

      public List<String> generatePaths()
      Generates all possible paths
      Returns:
      a list of paths containing at least one entry