Class TLcdModelTreeNodeUtil
Class with utility methods to work with ILcdModelTreeNodes. The
methods in this class are all thread-safe.
- Since:
- 9.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontainsModel(ILcdModel aModel, ILcdModelTreeNode aNode) ReturnstruewhenaModelis a child of the nodeaNode.static booleancontainsModelInTree(ILcdModel aModel, ILcdModel aRootNode) Returnstruewhen the modelaModelis an element of the tree with root nodeaRootNodestatic ILcdModelTreeNodegetFirstCommonAncestor(ILcdModel aFirstModel, ILcdModelTreeNode aFirstRootNode, ILcdModel aSecondModel, ILcdModelTreeNode aSecondRootNode) Returns the first ancestor that twoILcdModels have in common.static intgetModelCount(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 nodeaNodeby using a depth first search over the tree starting at nodeaNode.static ILcdModelTreeNodegetParent(ILcdModel aModel, ILcdModelTreeNode aRootNode) Finds the parent node ofaModelin the tree with root nodeaRootNode.getPath(ILcdModelTreeNode aFrom, ILcdModel aTo) Returns a list containing all theILcdModels to go fromaFromto the modelaTo.static List<ILcdModelTreeNode> getPathToParent(ILcdModelTreeNode aFrom, ILcdModel aTo) Returns a list containing all theILcdModelTreeNodes to go fromaFromto the parent ofaTo.static booleanisEmptyModel(ILcdModel aModel) Returnstruewhen the model is anILcdModelTreeNodeand 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
aNodeby using a depth first search over the tree starting at nodeaNode.- Parameters:
aNode- the start node for the search. Must not benullaIncludeNode-trueif the givenaNodeshould 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 theILcdModelTreeNodes to go fromaFromto the parent ofaTo. The list starts withaFromand 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
ILcdModelTreeNodes to go fromaFromto the parent ofaTo, ornullwhenaTois not a part of the tree with root nodeaTo
-
getPath
Returns a list containing all theILcdModels to go fromaFromto the modelaTo. The list starts withaFromand ends withaTo.- Parameters:
aFrom- the starting node of the pathaTo- the end node of the path- Returns:
- a list containing all the
ILcdModelto go fromaFromto the layeraTo, ornullwhenaTois not a part of the tree with root nodeaTo.
-
getParent
Finds the parent node of
aModelin 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, ornullwhen no parent can be found
-
containsModelInTree
Returns
truewhen the modelaModelis an element of the tree with root nodeaRootNode- Parameters:
aModel- the modelaRootNode- the root node of the tree- Returns:
truewhen the modelaModelis an element of the tree with root nodeaRootNode, false otherwise
-
containsModel
Returns
truewhenaModelis a child of the nodeaNode.- Parameters:
aModel- the modelaNode- the node- Returns:
truewhenaModelis a child of the nodeaNode,falsein all other cases
-
getFirstCommonAncestor
public static ILcdModelTreeNode getFirstCommonAncestor(ILcdModel aFirstModel, ILcdModelTreeNode aFirstRootNode, ILcdModel aSecondModel, ILcdModelTreeNode aSecondRootNode) Returns the first ancestor that twoILcdModels 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
aFirstModelandaSecondModel, ornullwhen the two models do not belong to the same tree
-
isEmptyModel
Returns
truewhen the model is anILcdModelTreeNodeand whenILcdModelTreeNode#isEmpty()returnstrue. Returnsfalsein all other cases.- Parameters:
aModel- the model to be checked- Returns:
truewhen the model is anILcdModelTreeNodeand whenILcdModelTreeNode#isEmpty()returnstrue
-