Interface NodePath<T>

Type Parameters:
T - the item type

public interface NodePath<T>

Identifies a node in a FilterTreeModel by the items on the path from the top level down to it.

An immutable value, equal to another path holding equal items in the same order, so the same item may appear in several places in a tree, each its own node. The root is the empty path, the invisible node above the top level.

A FilterTreeModel hands out the current path of each node, holding the item instances the model holds, which a refresh replaces with fresh ones, equal by equals(). A path held on to across a refresh still identifies the same node but holds the items it was created with.

See Also:
  • Method Details

    • item

      T item()
      Returns:
      the last item on this path, the item of the node it identifies
      Throws:
      IllegalStateException - in case this is the root path
    • items

      List<T> items()
      Returns:
      the items on this path, the top level item first, an empty list for the root path
    • parent

      NodePath<T> parent()
      Returns:
      the path of the parent node
      Throws:
      IllegalStateException - in case this is the root path
    • child

      NodePath<T> child(T item)
      Parameters:
      item - the child item
      Returns:
      the path of the child node holding the given item
    • depth

      int depth()
      Returns:
      the number of items on this path, 0 for the root path, 1 for the top level
    • root

      boolean root()
      Returns:
      true if this is the root path
    • contains

      boolean contains(NodePath<T> path)
      Parameters:
      path - the path
      Returns:
      true if the given path is this path or the path of a descendant
    • nodePath

      static <T> NodePath<T> nodePath()
      Type Parameters:
      T - the item type
      Returns:
      the root path
    • nodePath

      static <T> NodePath<T> nodePath(List<T> items)
      Type Parameters:
      T - the item type
      Parameters:
      items - the items, the top level item first
      Returns:
      a path holding the given items, the root path in case of no items
      Throws:
      NullPointerException - in case items is null or contains a null item