Class Tree.Branch<T>

java.lang.Object
uk.ac.starlink.vo.Tree<T>
uk.ac.starlink.vo.Tree.Branch<T>
Enclosing class:
Tree<T>

public static class Tree.Branch<T> extends Tree<T>
Tree instance that contains a list of children and no referenced item.
  • Constructor Details

    • Branch

      public Branch(List<Tree<T>> children, String label)
      Constructor.
      Parameters:
      children - list of child trees
      label - label for this branch, may be null
  • Method Details

    • getChildren

      public List<Tree<T>> getChildren()
      Returns this branch's children.
      Returns:
      list of child trees
    • getLabel

      public String getLabel()
      Returns this branch's label.
      Returns:
      label, may be null
    • isLeaf

      public boolean isLeaf()
      Description copied from class: Tree
      Returns true if this instance is a Leaf, false if it's a Branch.
      Specified by:
      isLeaf in class Tree<T>
      Returns:
      true iff this is a leaf
    • asLeaf

      public Tree.Leaf<T> asLeaf()
      Description copied from class: Tree
      Returns this instance as a Leaf if it's a leaf, or null if it's a branch.
      Specified by:
      asLeaf in class Tree<T>
      Returns:
      this cast to Leaf, or null
    • asBranch

      public Tree.Branch<T> asBranch()
      Description copied from class: Tree
      Returns this instance as a Branch if it's a branch, or null if it's a leaf.
      Specified by:
      asBranch in class Tree<T>
      Returns:
      this cast to Branch, or null
    • map

      public <R> Tree.Branch<R> map(Function<T,R> mapping)
      Description copied from class: Tree
      Recursively converts this Tree to one with the same structure, but with the leaf items mapped from their existing values to new values determined by a supplied mapping function.
      Specified by:
      map in class Tree<T>
      Parameters:
      mapping - mapping function
      Returns:
      tree with mapped values