Class BlockId


  • public final class BlockId
    extends java.lang.Object
    The BlockId class describes unique identifiers for instruction call blocks. The identifiers help uniquely identify elements that belong to different blocks, but have the same name. The identifier reflects the hierarchical structure of instruction call blocks.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  BlockId.Distance
      The Distance class describe a distance between blocks.
    • Constructor Summary

      Constructors 
      Constructor Description
      BlockId()
      Constructs a identifier for a root block.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • BlockId

        public BlockId()
        Constructs a identifier for a root block.
    • Method Detail

      • nextChildId

        public BlockId nextChildId()
        Creates an new identifier for a child block.
        Returns:
        Next child identifier.
      • parentId

        public BlockId parentId()
        Returns the identifier of the parent block or null if there is no parent block (the current one is root).
        Returns:
        Parent identifier or null if there is no parent.
      • isRoot

        public boolean isRoot()
        Checks whether the current block is a root block (has no parent).
        Returns:
        true is this is a root block or false otherwise.
      • isParent

        public 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. Note: a block is not a parent to itself.
        Parameters:
        parentId - Identifier of the candidate parent block.
        Returns:
        true if the specified block identifier refers to a parent block or false otherwise.
        Throws:
        java.lang.IllegalArgumentException - if the parameter is null.
      • isChild

        public 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. Note: a block is not a child to itself.
        Parameters:
        childId - Identifier of the candidate child block.
        Returns:
        true if the specified block identifier refers to a child block or false otherwise.
        Throws:
        java.lang.IllegalArgumentException - if the parameter is null.
      • getDepth

        public int getDepth()
        Returns the depth of nesting for the block described by the current identifier.
        Returns:
        Nesting depth of the block described by the identifier.
      • getDistance

        public 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).
        Parameters:
        target - Target block.
        Returns:
        Distance from the current block to the target block.
        Throws:
        java.lang.IllegalArgumentException - if the parameter is null.
      • toString

        public java.lang.String toString()
        Returns textual representation of the identifier.
        Overrides:
        toString in class java.lang.Object
        Returns:
        Textual representation of the identifier.
      • hashCode

        public 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.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        Hash code for the block identifier.
      • equals

        public boolean equals​(java.lang.Object obj)
        Checks whether the specified object is a block identifier that is equal to the current one.
        Overrides:
        equals in class java.lang.Object
        Returns:
        true the object refers to an equal block identifier or false otherwise.