public class TLcdModelTreeNodeUtil extends Object
Class with utility methods to work with ILcdModelTreeNode
s. The
methods in this class are all thread-safe.
Modifier and Type | Method and Description |
---|---|
static boolean |
containsModel(ILcdModel aModel,
ILcdModelTreeNode aNode)
Returns
true when aModel is a child of the node aNode . |
static boolean |
containsModelInTree(ILcdModel aModel,
ILcdModel aRootNode)
Returns
true when the model aModel is an element of the tree with
root node aRootNode |
static ILcdModelTreeNode |
getFirstCommonAncestor(ILcdModel aFirstModel,
ILcdModelTreeNode aFirstRootNode,
ILcdModel aSecondModel,
ILcdModelTreeNode aSecondRootNode)
Returns the first ancestor that two
ILcdModel s have in common. |
static int |
getModelCount(ILcdModel aModel)
Returns the total number of models and model nodes in the tree with root node
aModel , including aModel . |
static List<ILcdModel> |
getModels(ILcdModelTreeNode aNode)
Returns a list containing all the models underneath the node
aNode , including
aNode , by using a depth first search over trhe tree with root node
aNode . |
static List<ILcdModel> |
getModels(ILcdModelTreeNode aNode,
boolean aIncludeNode)
Returns a list containing all the models underneath the node
aNode by using a
depth first search over the tree starting at node aNode . |
static ILcdModelTreeNode |
getParent(ILcdModel aModel,
ILcdModelTreeNode aRootNode)
Finds the parent node of
aModel in the tree with root node
aRootNode . |
static List<ILcdModel> |
getPath(ILcdModelTreeNode aFrom,
ILcdModel aTo)
Returns a list containing all the
ILcdModel s to go from aFrom to the
model aTo . |
static List<ILcdModelTreeNode> |
getPathToParent(ILcdModelTreeNode aFrom,
ILcdModel aTo)
Returns a list containing all the
ILcdModelTreeNode s to go from aFrom
to the parent of aTo . |
static boolean |
isEmptyModel(ILcdModel aModel)
Returns
true when the model is an ILcdModelTreeNode and
when ILcdModelTreeNode#isEmpty()
returns true . |
public static List<ILcdModel> getModels(ILcdModelTreeNode aNode)
Returns a list containing all the models underneath the node aNode
, including
aNode
, by using a depth first search over trhe tree with root node
aNode
.
aNode
- the start node for the search. Must not be null
aNode
public static List<ILcdModel> getModels(ILcdModelTreeNode aNode, boolean aIncludeNode)
Returns a list containing all the models underneath the node aNode
by using a
depth first search over the tree starting at node aNode
.
aNode
- the start node for the search. Must not be null
aIncludeNode
- true
if the given aNode
should be part of the
returned listpublic static int getModelCount(ILcdModel aModel)
Returns the total number of models and model nodes in the tree with root node
aModel
, including aModel
.
aModel
- the root node of the treeaModel
public static List<ILcdModelTreeNode> getPathToParent(ILcdModelTreeNode aFrom, ILcdModel aTo)
ILcdModelTreeNode
s to go from aFrom
to the parent of aTo
. The list starts with aFrom
and ends with the
parent node.aFrom
- the starting node of the path. Must be different from aTo
.aTo
- the node for which the path to its parent must be found. Must be different from aFrom
.ILcdModelTreeNode
s to go from aFrom
to the parent of aTo
, or null
when aTo
is not a
part of the tree with root node aTo
public static List<ILcdModel> getPath(ILcdModelTreeNode aFrom, ILcdModel aTo)
ILcdModel
s to go from aFrom
to the
model aTo
. The list starts with aFrom
and ends with
aTo
.aFrom
- the starting node of the pathaTo
- the end node of the pathILcdModel
to go from aFrom
to the
layer aTo
, or null
when aTo
is not a part of the
tree with root node aTo
.public static ILcdModelTreeNode getParent(ILcdModel aModel, ILcdModelTreeNode aRootNode)
Finds the parent node of aModel
in the tree with root node
aRootNode
.
aModel
- the model for which the parent is searchedaRootNode
- the root node of the tree to be searchedaModel
, or null
when no parent can be
foundpublic static boolean containsModelInTree(ILcdModel aModel, ILcdModel aRootNode)
Returns true
when the model aModel
is an element of the tree with
root node aRootNode
aModel
- the modelaRootNode
- the root node of the treetrue
when the model aModel
is an element of the tree with
root node aRootNode
, false otherwisepublic static boolean containsModel(ILcdModel aModel, ILcdModelTreeNode aNode)
Returns true
when aModel
is a child of the node aNode
.
aModel
- the modelaNode
- the nodetrue
when aModel
is a child of the node aNode
,
false
in all other casespublic static ILcdModelTreeNode getFirstCommonAncestor(ILcdModel aFirstModel, ILcdModelTreeNode aFirstRootNode, ILcdModel aSecondModel, ILcdModelTreeNode aSecondRootNode)
ILcdModel
s have in common. When no common
ancestor is found, this method will return null
. This is only possible when the
two models are not part of the same tree. Otherwise the root node will be the common ancestoraFirstModel
- 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 nodeaFirstModel
and aSecondModel
, or
null
when the two models do not belong to the same treepublic static boolean isEmptyModel(ILcdModel aModel)
Returns true
when the model is an ILcdModelTreeNode
and
when ILcdModelTreeNode#isEmpty()
returns true
. Returns false
in all other cases.
aModel
- the model to be checkedtrue
when the model is an ILcdModelTreeNode
and
when ILcdModelTreeNode#isEmpty()
returns true