public class ImmutableTree extends Object
implements Iterable<Entry<Path, T>>

Nested Class Summary

interface ImmutableTree.TreeVisitor<T, R>  

Public Constructor Summary

ImmutableTree(T value, ImmutableSortedMap<ChildKeyImmutableTree<T>> children)
ImmutableTree(T value)

Public Method Summary

boolean
containsMatchingValue(Predicate<? super T> predicate)
static <V> ImmutableTree<V>
boolean
Path
findRootMostMatchingPath(Path relativePath, Predicate<? super T> predicate)
Path
<R> R
fold(R accum, TreeVisitor<? super T, R> visitor)
void
foreach(TreeVisitor<T, Void> visitor)
T
get(Path relativePath)
ImmutableTree<T>
ImmutableSortedMap<ChildKeyImmutableTree<T>>
T
int
boolean
Iterator<Entry<Path, T>>
T
leafMostValue(Path relativePath)
T
leafMostValueMatching(Path path, Predicate<? super T> predicate)
Returns the deepest value found between the root and the specified path that matches the predicate.
ImmutableTree<T>
remove(Path relativePath)
T
rootMostValue(Path relativePath)
T
rootMostValueMatching(Path relativePath, Predicate<? super T> predicate)
ImmutableTree<T>
set(Path relativePath, T value)
ImmutableTree<T>
setTree(Path relativePath, ImmutableTree<T> newTree)
ImmutableTree<T>
subtree(Path relativePath)
String
Collection<T>
values()

Inherited Method Summary

Public Constructors

public ImmutableTree (T value, ImmutableSortedMap<ChildKeyImmutableTree<T>> children)

Parameters
value
children

public ImmutableTree (T value)

Parameters
value

Public Methods

public boolean containsMatchingValue (Predicate<? super T> predicate)

Parameters
predicate

public static ImmutableTree<V> emptyInstance ()

public boolean equals (Object o)

Parameters
o

public Path findRootMostMatchingPath (Path relativePath, Predicate<? super T> predicate)

Parameters
relativePath
predicate

public Path findRootMostPathWithValue (Path relativePath)

Parameters
relativePath

public R fold (R accum, TreeVisitor<? super T, R> visitor)

Parameters
accum
visitor

public void foreach (TreeVisitor<T, Void> visitor)

Parameters
visitor

public T get (Path relativePath)

Parameters
relativePath

public ImmutableTree<T> getChild (ChildKey child)

Parameters
child

public ImmutableSortedMap<ChildKeyImmutableTree<T>> getChildren ()

public T getValue ()

public int hashCode ()

public boolean isEmpty ()

public Iterator<Entry<Path, T>> iterator ()

public T leafMostValue (Path relativePath)

Parameters
relativePath

public T leafMostValueMatching (Path path, Predicate<? super T> predicate)

Returns the deepest value found between the root and the specified path that matches the predicate.

Parameters
path Path along which to look for matching values.
predicate The predicate to evaluate values against.
Returns
  • The deepest matching value, or null if no value matches.

public ImmutableTree<T> remove (Path relativePath)

Parameters
relativePath

public T rootMostValue (Path relativePath)

Parameters
relativePath

public T rootMostValueMatching (Path relativePath, Predicate<? super T> predicate)

Parameters
relativePath
predicate

public ImmutableTree<T> set (Path relativePath, T value)

Parameters
relativePath
value

public ImmutableTree<T> setTree (Path relativePath, ImmutableTree<T> newTree)

Parameters
relativePath
newTree

public ImmutableTree<T> subtree (Path relativePath)

Parameters
relativePath

public String toString ()

public Collection<T> values ()