public final class BlockId
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
BlockId.Distance
The Distance class describe a distance between blocks.
|
Constructor and Description |
---|
BlockId()
Constructs a identifier for a root block.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Checks whether the specified object is a block identifier that is equal to the current one.
|
int |
getDepth()
Returns the depth of nesting for the block described by the current identifier.
|
BlockId.Distance |
getDistance(BlockId target)
Calculates the distance between the current block and the target block (the path you need to
pass to get from the current one to the target one).
|
int |
hashCode()
Calculates the hash code of the block identifier based on the elements of the indexes list
which describes the relative location of the block.
|
boolean |
isChild(BlockId childId)
Checks whether the specified block identifier refers to a block which is a child (not necessary
immediate) of the block marked by the current identifier.
|
boolean |
isParent(BlockId parentId)
Checks whether the specified block identifier refers to a block which is a parent (not
necessary immediate) of the block marked by the current identifier.
|
boolean |
isRoot()
Checks whether the current block is a root block (has no parent).
|
BlockId |
nextChildId()
Creates an new identifier for a child block.
|
BlockId |
parentId()
Returns the identifier of the parent block or
null if there
is no parent block (the current one is root). |
java.lang.String |
toString()
Returns textual representation of the identifier.
|
public BlockId nextChildId()
public BlockId parentId()
null
if there
is no parent block (the current one is root).null
if there is no parent.public boolean isRoot()
true
is this is a root block or false
otherwise.public boolean isParent(BlockId parentId)
parentId
- Identifier of the candidate parent block.true
if the specified block identifier refers to a parent block or
false
otherwise.java.lang.IllegalArgumentException
- if the parameter is null
.public boolean isChild(BlockId childId)
childId
- Identifier of the candidate child block.true
if the specified block identifier refers to a child block or
false
otherwise.java.lang.IllegalArgumentException
- if the parameter is null
.public int getDepth()
public BlockId.Distance getDistance(BlockId target)
target
- Target block.java.lang.IllegalArgumentException
- if the parameter is null
.public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
true
the object refers to an equal block identifier or
false
otherwise.