Package io.molr.mole.core.tree
Class TreeStructure
- java.lang.Object
-
- io.molr.mole.core.tree.TreeStructure
-
public class TreeStructure extends Object
TODO #1 consider merging with MissionRepresentation
-
-
Constructor Summary
Constructors Constructor Description TreeStructure(MissionRepresentation representation, Set<Block> parallelBlocks, Map<Block,Integer> maxConcurrency)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<Block>
allBlocks()
List<Block>
childrenOf(Block block)
boolean
contains(Block block)
boolean
equals(Object o)
int
hashCode()
boolean
isDescendantOf(Block target, Block source)
Determines whether or not thetarget
is a descendant of thesource
block in this structure.boolean
isLeaf(Block block)
boolean
isParallel(Block block)
int
maxConcurrency(Block block)
MissionRepresentation
missionRepresentation()
Optional<Block>
nextBlock(Block actualBlock)
Optionally returns the next block in the tree structure of the specified parameter.Set<Block>
parallelBlocks()
Optional<Block>
parentOf(Block block)
static String
print(TreeStructure structure)
Block
rootBlock()
TreeStructure
substructure(Block block)
Returns a newTreeStructure
with the specifiedBlock
as root.TreeStructure
substructure(Block block, String postfix)
-
-
-
Method Detail
-
substructure
public TreeStructure substructure(Block block)
Returns a newTreeStructure
with the specifiedBlock
as root. It will not return a view of this structure but a completely new one.NOTE: The current implementation is not optimized for performance...
- Parameters:
block
- the block which shall be the root of the new tree structure- Returns:
- a new tree structure, with the given block as root.
-
substructure
public TreeStructure substructure(Block block, String postfix)
-
nextBlock
public Optional<Block> nextBlock(Block actualBlock)
Optionally returns the next block in the tree structure of the specified parameter. Since this method does not know the history of the movements, it will not return as next block a children of the parameter. On the contrary, if the parameter is the last child of a sequence, it will automatically resolve the sibling of the parent as the next block. An emptyOptional
indicates that there is no next block and the tree navigation can be considered finished- Parameters:
actualBlock
- the actual block for which to retrieve the next- Returns:
- an optional containing the next block to navigate to or an empty optional, if there is no next block.
-
isParallel
public boolean isParallel(Block block)
-
maxConcurrency
public int maxConcurrency(Block block)
-
isLeaf
public boolean isLeaf(Block block)
-
rootBlock
public Block rootBlock()
-
contains
public boolean contains(Block block)
-
missionRepresentation
public MissionRepresentation missionRepresentation()
-
isDescendantOf
public boolean isDescendantOf(Block target, Block source)
Determines whether or not thetarget
is a descendant of thesource
block in this structure.NOTE: The current implementation is not optimized for performance...
- Parameters:
target
- the target, for which to check if it is a descendant of the sourcesource
- the source for which to check if the target is a descendant of it- Returns:
true
if the given target is a descendant of the given source,false
otherwise.
-
print
public static String print(TreeStructure structure)
-
-