public abstract class Tree<T> extends Object
Tree.Leaf
or
Tree.Branch
.
Node might be a better name than Tree, but since it's used with
DOM parsing I want to avoid a name clash with
org.w3c.dom.Node
.
Modifier and Type | Class and Description |
---|---|
static class |
Tree.Branch<T>
Tree instance that contains a list of children and no referenced item.
|
static class |
Tree.Leaf<T>
Tree instance that contains a referenced item and no children.
|
Modifier and Type | Method and Description |
---|---|
abstract Tree.Branch<T> |
asBranch()
Returns this instance as a Branch if it's a branch,
or null if it's a leaf.
|
abstract Tree.Leaf<T> |
asLeaf()
Returns this instance as a Leaf if it's a leaf,
or null if it's a branch.
|
abstract boolean |
isLeaf()
Returns true if this instance is a Leaf, false if it's a Branch.
|
abstract <R> Tree<R> |
map(java.util.function.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.
|
public abstract boolean isLeaf()
public abstract Tree.Leaf<T> asLeaf()
public abstract Tree.Branch<T> asBranch()
public abstract <R> Tree<R> map(java.util.function.Function<T,R> mapping)
mapping
- mapping functionCopyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.