Package io.crums.util.mrkl.index
Class AbstractNode
java.lang.Object
io.crums.util.mrkl.index.AbstractNode
- Direct Known Subclasses:
Node
public abstract class AbstractNode
extends java.lang.Object
Breadth-first coordinates of a node in a Merkle tree.
-
Field Summary
Fields Modifier and Type Field Description static TreeIndex.NodeFactory<AbstractNode>FACTORYStateless factory. -
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractNode(int level, int index) -
Method Summary
Modifier and Type Method Description booleanequals(java.lang.Object o)Equality semantics are governed by coordinates and handedness.inthashCode()intindex()Returns this node's index (at this level).booleanisLeaf()Determines whether this node is at level zero.booleanisLeft()Determines whether this node is the left child of its parent.abstract booleanisRight()Determines whether this node is the right child of its parent.intlevel()Returns this node's level.java.lang.StringtoString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
FACTORY
Stateless factory.
-
-
Constructor Details
-
AbstractNode
protected AbstractNode(int level, int index) throws java.lang.IndexOutOfBoundsException- Throws:
java.lang.IndexOutOfBoundsException
-
-
Method Details
-
level
public final int level()Returns this node's level. Levels are counted from the bottom up: zero at the leaves, maximum at root. -
isLeaf
public final boolean isLeaf()Determines whether this node is at level zero. -
index
public final int index()Returns this node's index (at this level). -
isLeft
public final boolean isLeft()Determines whether this node is the left child of its parent. Note, for closure reasons the root node is defined to be left. -
isRight
public abstract boolean isRight()Determines whether this node is the right child of its parent.Implementations should be marked final.
-
equals
public final boolean equals(java.lang.Object o)Equality semantics are governed by coordinates and handedness.- Overrides:
equalsin classjava.lang.Object
-
hashCode
public final int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-