Class TLcdModelTreeNodeUtil
Class with utility methods to work with ILcdModelTreeNode
s. The
methods in this class are all thread-safe.
- Since:
- 9.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
containsModel
(ILcdModel aModel, ILcdModelTreeNode aNode) Returnstrue
whenaModel
is a child of the nodeaNode
.static boolean
containsModelInTree
(ILcdModel aModel, ILcdModel aRootNode) Returnstrue
when the modelaModel
is an element of the tree with root nodeaRootNode
static ILcdModelTreeNode
getFirstCommonAncestor
(ILcdModel aFirstModel, ILcdModelTreeNode aFirstRootNode, ILcdModel aSecondModel, ILcdModelTreeNode aSecondRootNode) Returns the first ancestor that twoILcdModel
s have in common.static int
getModelCount
(ILcdModel aModel) Returns the total number of models and model nodes in the tree with root nodeaModel
, includingaModel
.getModels
(ILcdModelTreeNode aNode) Returns a list containing all the models underneath the nodeaNode
, includingaNode
, by using a depth first search over trhe tree with root nodeaNode
.getModels
(ILcdModelTreeNode aNode, boolean aIncludeNode) Returns a list containing all the models underneath the nodeaNode
by using a depth first search over the tree starting at nodeaNode
.static ILcdModelTreeNode
getParent
(ILcdModel aModel, ILcdModelTreeNode aRootNode) Finds the parent node ofaModel
in the tree with root nodeaRootNode
.getPath
(ILcdModelTreeNode aFrom, ILcdModel aTo) Returns a list containing all theILcdModel
s to go fromaFrom
to the modelaTo
.static List
<ILcdModelTreeNode> getPathToParent
(ILcdModelTreeNode aFrom, ILcdModel aTo) Returns a list containing all theILcdModelTreeNode
s to go fromaFrom
to the parent ofaTo
.static boolean
isEmptyModel
(ILcdModel aModel) Returnstrue
when the model is anILcdModelTreeNode
and whenILcdModelTreeNode#isEmpty()
returnstrue
.
-
Method Details
-
getModels
Returns a list containing all the models underneath the node
aNode
, includingaNode
, by using a depth first search over trhe tree with root nodeaNode
.- Parameters:
aNode
- the start node for the search. Must not benull
- Returns:
- a list containing over all the underlying models, including the node
aNode
-
getModels
Returns a list containing all the models underneath the node
aNode
by using a depth first search over the tree starting at nodeaNode
.- Parameters:
aNode
- the start node for the search. Must not benull
aIncludeNode
-true
if the givenaNode
should be part of the returned list- Returns:
- a list containing all the underlying models
-
getModelCount
Returns the total number of models and model nodes in the tree with root node
aModel
, includingaModel
.- Parameters:
aModel
- the root node of the tree- Returns:
- the total number of models and model nodes in the tree with root node
aModel
-
getPathToParent
Returns a list containing all theILcdModelTreeNode
s to go fromaFrom
to the parent ofaTo
. The list starts withaFrom
and ends with the parent node.- Parameters:
aFrom
- the starting node of the path. Must be different fromaTo
.aTo
- the node for which the path to its parent must be found. Must be different fromaFrom
.- Returns:
- a list containing all the
ILcdModelTreeNode
s to go fromaFrom
to the parent ofaTo
, ornull
whenaTo
is not a part of the tree with root nodeaTo
-
getPath
Returns a list containing all theILcdModel
s to go fromaFrom
to the modelaTo
. The list starts withaFrom
and ends withaTo
.- Parameters:
aFrom
- the starting node of the pathaTo
- the end node of the path- Returns:
- a list containing all the
ILcdModel
to go fromaFrom
to the layeraTo
, ornull
whenaTo
is not a part of the tree with root nodeaTo
.
-
getParent
Finds the parent node of
aModel
in the tree with root nodeaRootNode
.- Parameters:
aModel
- the model for which the parent is searchedaRootNode
- the root node of the tree to be searched- Returns:
- the parent node for
aModel
, ornull
when no parent can be found
-
containsModelInTree
Returns
true
when the modelaModel
is an element of the tree with root nodeaRootNode
- Parameters:
aModel
- the modelaRootNode
- the root node of the tree- Returns:
true
when the modelaModel
is an element of the tree with root nodeaRootNode
, false otherwise
-
containsModel
Returns
true
whenaModel
is a child of the nodeaNode
.- Parameters:
aModel
- the modelaNode
- the node- Returns:
true
whenaModel
is a child of the nodeaNode
,false
in all other cases
-
getFirstCommonAncestor
public static ILcdModelTreeNode getFirstCommonAncestor(ILcdModel aFirstModel, ILcdModelTreeNode aFirstRootNode, ILcdModel aSecondModel, ILcdModelTreeNode aSecondRootNode) Returns the first ancestor that twoILcdModel
s have in common. When no common ancestor is found, this method will returnnull
. This is only possible when the two models are not part of the same tree. Otherwise the root node will be the common ancestor- Parameters:
aFirstModel
- the first modelaFirstRootNode
- the root node of the tree containing the first nodeaSecondModel
- the second modelaSecondRootNode
- the root node of the tree containing the second node- Returns:
- the first common ancestor of
aFirstModel
andaSecondModel
, ornull
when the two models do not belong to the same tree
-
isEmptyModel
Returns
true
when the model is anILcdModelTreeNode
and whenILcdModelTreeNode#isEmpty()
returnstrue
. Returnsfalse
in all other cases.- Parameters:
aModel
- the model to be checked- Returns:
true
when the model is anILcdModelTreeNode
and whenILcdModelTreeNode#isEmpty()
returnstrue
-