Class Tree.Leaf<T>

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

public static class Tree.Leaf<T> extends Tree<T>
Tree instance that contains a referenced item and no children.
  • Nested Class Summary

    Nested classes/interfaces inherited from class uk.ac.starlink.vo.Tree

    Tree.Branch<T>, Tree.Leaf<T>
  • Constructor Summary

    Constructors
    Constructor
    Description
    Leaf(T item)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns this instance as a Branch if it's a branch, or null if it's a leaf.
    Returns this instance as a Leaf if it's a leaf, or null if it's a branch.
    Returns the item referenced by this leaf.
    boolean
    Returns true if this instance is a Leaf, false if it's a Branch.
    <R> Tree.Leaf<R>
    map(Function<T,R> mapping)
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Leaf

      public Leaf(T item)
      Constructor.
      Parameters:
      item - item held by this leaf
  • Method Details

    • getItem

      public T getItem()
      Returns the item referenced by this leaf.
      Returns:
      item
    • 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.Leaf<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