Interface NamedNode

  • All Superinterfaces:
    java.lang.Comparable<NamedNode>
    All Known Subinterfaces:
    FolderNode, LeafNode

    public interface NamedNode
    extends java.lang.Comparable<NamedNode>
    A named node in a hierarchy. Paths in the hierarchy are using the '/' as separator. A hierarchy consists of Folder and Leafs. It is rooted in a root FolderNode that is the only node without a parent. The root has an empty name. I.e. not '/'

    A NamedNode hashCode & equals are based on identity. They are, however, Comparable

    A Named Node is either a Folder or a Leaf, there are no other types.

    • Method Detail

      • name

        java.lang.String name()
        The name of this node. This name is always without a '/'.
        Returns:
        the name
      • path

        java.lang.String path()
        The path of this node in the hierarchy. This path never starts with a '/'. If it is a folder, the path must end with a '/'.

        This path, when used with Hierarchy.find(String) must return the this node.

        Returns:
        the name
      • parent

        java.util.Optional<? extends FolderNode> parent()
        Return the parent of this node. Only the root will return an empty Optional. Each hierarchy has a single root.
        Returns:
        the parent or an empty Optional in the case of the root node.
      • find

        java.util.Optional<NamedNode> find​(java.lang.String path)
        Find a path from this node down. The `..` and '.' are supported, meaning parent and this.
        Parameters:
        path - the path
        Returns:
        an optional node if found
      • isFolder

        default boolean isFolder()
        Returns:
        true if this is a FolderNode
      • isLeaf

        default boolean isLeaf()
        Returns:
        true if this is not a FolderNode
      • isRoot

        default boolean isRoot()
        Returns:
        true if this is the root node.
      • siblings

        default java.util.Optional<NamedNode[]> siblings()
        Return the siblings of this node.
        Returns:
        the siblings or empty if the root node