org.javimmutable.collections.tree
Class LeafNode<K,V>

java.lang.Object
  extended by org.javimmutable.collections.tree.TreeNode<K,V>
      extended by org.javimmutable.collections.tree.LeafNode<K,V>
All Implemented Interfaces:
Cursorable<JImmutableMap.Entry<K,V>>, Holder<V>, JImmutableMap.Entry<K,V>

@Immutable
public class LeafNode<K,V>
extends TreeNode<K,V>
implements JImmutableMap.Entry<K,V>, Holder<V>


Constructor Summary
LeafNode(K key, V value)
           
 
Method Summary
 void addEntriesTo(Collection<JImmutableMap.Entry<K,V>> collection)
          Adds this node's value and all of its children's value to the collection.
 Cursor<JImmutableMap.Entry<K,V>> cursor()
          Returns a Cursor visiting all entries in sorted order.
 boolean equals(Object o)
           
 Holder<V> find(Comparator<K> props, K searchKey)
          Return a (possibly empty) Holder containing the value matching key.
 Holder<JImmutableMap.Entry<K,V>> findEntry(Comparator<K> props, K searchKey)
          Return a (possibly empty) Holder containing the an Entry matching key.
 K getKey()
           
 V getValue()
          Retrieve the value of a filled Holder.
 V getValueOr(Comparator<K> props, K searchKey, V defaultValue)
          Return the value matching key or defaultValue if no match is found.
 V getValueOr(V defaultValue)
          Retrieve the value of a filled Holder or the defaultValue if Holder is empty
 V getValueOrNull()
          Retrieve the value of a filled Holder or null if Holder is empty.
 int hashCode()
           
 boolean isEmpty()
          Return true if this node contains no children or value.
 boolean isFilled()
           
 String toString()
           
 int verifyDepthsMatch()
           
 
Methods inherited from class org.javimmutable.collections.tree.TreeNode
assign, delete, of
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LeafNode

public LeafNode(K key,
                V value)
Method Detail

getKey

@Nonnull
public K getKey()
Specified by:
getKey in interface JImmutableMap.Entry<K,V>

getValue

public V getValue()
Description copied from interface: Holder
Retrieve the value of a filled Holder. Must throw if Holder is empty.

Specified by:
getValue in interface Holder<V>
Specified by:
getValue in interface JImmutableMap.Entry<K,V>
Returns:
the (possibly null) value

isEmpty

public boolean isEmpty()
Description copied from class: TreeNode
Return true if this node contains no children or value.

Specified by:
isEmpty in interface Holder<V>
Overrides:
isEmpty in class TreeNode<K,V>
Returns:
true iff this Holder has no value to return

isFilled

public boolean isFilled()
Specified by:
isFilled in interface Holder<V>
Returns:
true iff this Holder has a value to return

getValueOrNull

public V getValueOrNull()
Description copied from interface: Holder
Retrieve the value of a filled Holder or null if Holder is empty.

Specified by:
getValueOrNull in interface Holder<V>
Returns:
null (empty) or value (filled)

getValueOr

public V getValueOr(V defaultValue)
Description copied from interface: Holder
Retrieve the value of a filled Holder or the defaultValue if Holder is empty

Specified by:
getValueOr in interface Holder<V>
Parameters:
defaultValue - value to return if Holder is empty
Returns:
value or defaultValue

getValueOr

public V getValueOr(Comparator<K> props,
                    K searchKey,
                    V defaultValue)
Description copied from class: TreeNode
Return the value matching key or defaultValue if no match is found. Searches this node and its appropriate children.

Specified by:
getValueOr in class TreeNode<K,V>
Returns:

find

public Holder<V> find(Comparator<K> props,
                      K searchKey)
Description copied from class: TreeNode
Return a (possibly empty) Holder containing the value matching key. Searches this node and its appropriate children.

Specified by:
find in class TreeNode<K,V>
Returns:

findEntry

public Holder<JImmutableMap.Entry<K,V>> findEntry(Comparator<K> props,
                                                  K searchKey)
Description copied from class: TreeNode
Return a (possibly empty) Holder containing the an Entry matching key. Searches this node and its appropriate children.

Specified by:
findEntry in class TreeNode<K,V>
Returns:

addEntriesTo

public void addEntriesTo(Collection<JImmutableMap.Entry<K,V>> collection)
Description copied from class: TreeNode
Adds this node's value and all of its children's value to the collection.

Specified by:
addEntriesTo in class TreeNode<K,V>

verifyDepthsMatch

public int verifyDepthsMatch()

toString

public String toString()
Overrides:
toString in class Object

cursor

@Nonnull
public Cursor<JImmutableMap.Entry<K,V>> cursor()
Description copied from class: TreeNode
Returns a Cursor visiting all entries in sorted order.

Specified by:
cursor in interface Cursorable<JImmutableMap.Entry<K,V>>
Specified by:
cursor in class TreeNode<K,V>

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2014 Burton Computer Corporation. All rights reserved.