Class ParameterizedPath

java.lang.Object
dev.getelements.elements.sdk.cluster.path.ParameterizedPath
All Implemented Interfaces:
Serializable

public final class ParameterizedPath extends Object implements Serializable
Similar to Path, but supports the parsing of parameters to the path. Final Path instances may be generated by applying the parameters specified. Created by patricktwohig on 8/16/17.
See Also:
  • Constructor Details

  • Method Details

    • getRaw

      public Path getRaw()
      Gets the underlying raw Path instance.
      Returns:
      the Path instance
    • getParameters

      public List<String> getParameters()
      Gets the components of the underlying Path which are parameterized.
      Returns:
      a listing of all parameters, stripped of the curly braces
    • resolve

      public Path resolve(Map<String,String> parameters)
      Resolves all parameters in this ParameterizedPath with the supplied mapping of parameters.
      Parameters:
      parameters - the parameters map
      Returns:
      a fully resolved Path
    • resolve

      public Path resolve(Function<String,String> resolver)
      Resolves this instance against the supplied Function<String,String> which provides a mapping of parameters to their values.
      Parameters:
      resolver - the resolver, which may return null if the parameter is unresolved.
      Returns:
      the resolved Path instance, never null
      Throws:
      IllegalArgumentException - if the supplied resolver cannot resolve the parameters
    • matches

      public boolean matches(Path path)
      Checks if this ParameterizedPath matches the supplied Path. A Path matches this ParameterizedPath if it has the same number of components and each component is equal to the patch or corresponds to a parameter.
      Parameters:
      path - the Path
      Returns:
      true if this Path matches
    • extract

      public Map<String,String> extract(Path path)
      Given the provided non-parameterized path, this will return a Map<String,String> of the value of the parameters. The supplied Path must match this instance using matches(Path) for this method to succeed. The ordering of the returned Map<String,String> will be returned in the order in which the mapping matched the original Path.
      Parameters:
      path - the Path which matches this
      Returns:
      the mapping of parameter names to the supplied Path
      Throws:
      IllegalArgumentException - if the Path does not match
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object