Class Paths.Node

java.lang.Object
lib.aide.paths.Paths.Node
Enclosing class:
Paths<C,P>

public class Paths.Node extends Object
Represents a node in the hierarchical path structure.
  • Constructor Details

    • Node

      public Node(List<C> components, Optional<P> payload, Paths<C,P>.Node parent)
      Constructs a new Node with the specified components, payload, and parent node.
      Parameters:
      components - the components of the path for this node
      payload - the payload associated with this node
      parent - the parent node
  • Method Details

    • components

      public List<C> components()
    • payload

      public Optional<P> payload()
    • setPayload

      public void setPayload(Optional<P> payload)
    • parent

      public Paths<C,P>.Node parent()
    • addChild

      public void addChild(Paths<C,P>.Node child)
    • addAttribute

      public void addAttribute(String key, Object value)
    • mergeAttributes

      public List<Map.Entry<String,Paths.DeepMergeOperation>> mergeAttributes(Map<String,Object> updates)
    • getAttribute

      public Optional<Object> getAttribute(String key)
    • addIssue

      public void addIssue(Exception e)
    • findChild

      public Optional<Paths<C,P>.Node> findChild(C component)
    • siblings

      public List<Paths<C,P>.Node> siblings(boolean withSelf)
    • descendants

      public List<Paths<C,P>.Node> descendants()
    • ancestors

      public List<Paths<C,P>.Node> ancestors()
    • isRoot

      public boolean isRoot()
    • isLeaf

      public boolean isLeaf()
    • absolutePath

      public String absolutePath(boolean includeRoot)
    • absolutePath

      public String absolutePath()
    • basename

      public Optional<C> basename()
    • children

      public List<Paths<C,P>.Node> children()
    • attributes

      public Map<String,Object> attributes()
    • issues

      public List<Exception> issues()
    • populate

      public void populate(List<C> components, Optional<P> payload, int index, Paths.InterimPayloadSupplier<C,P> ips)
      Populates the tree structure with the specified components and payload. If a parent is not already created, it's called an "interim" node and will have an "interim payload" which can be empty for default behavior. An empty interim payload will be filled in with a final payload if it's supplied later.
      Parameters:
      components - the components to add
      payload - payload associated with the terminal component
      index - the current index in the components list
      ips - payload associated with an interim component
    • resolve

      public Optional<Paths<C,P>.Node> resolve(List<C> relativeComponents)
      Resolves the relative components to a node in the tree structure.
      Parameters:
      relativeComponents - the relative components to resolve
      Returns:
      an Optional containing the resolved node if found, or an empty Optional
    • resolve

      public Optional<Paths<C,P>.Node> resolve(String relativePath)
      Resolves the relative path to a node in the tree structure.
      Parameters:
      relativePath - the relative path to resolve
      Returns:
      an Optional containing the resolved node if found, or an empty Optional
    • toString

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

      public void forEach(Consumer<? super Paths<C,P>.Node> action, boolean depthFirst)
      Runs action for every node in the tree, depth first
      Parameters:
      action - callback to run
      depthFirst - true to run depth-first