public class FlexTreeUtils extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
allLeafsMatch(TreePath[] paths,
Class<?> type)
Return whether all leafs (last path components) of the given paths match
the given type.
|
static <T> List<T> |
getMatchingLeafs(TreePath[] paths,
Class<T> type)
Return the matching leaf objects (last path components) of the given paths
matching the given type.
|
static List<TreePath> |
getMatchingPaths(TreePath[] paths,
Class<?> type)
Return those paths whose leaf objects (last path components) of the given
paths match the given type.
|
static <T> T |
locateCommonParent(TreePath[] paths,
Class<T> type)
Locate a common element of the given type within the given paths.
|
static <T> T |
locateLast(TreePath path,
Class<T> type)
find that object of the given class, which is nearest to a leaf (and
farthest from the root).
|
static boolean |
someLeafsMatch(TreePath[] paths,
Class<?> type)
Return whether at least one leaf (last path component) of the given paths
matches the given type.
|
public static <T> T locateLast(TreePath path, Class<T> type)
null
is returned.public static boolean someLeafsMatch(TreePath[] paths, Class<?> type)
paths
- the paths to testtype
- the type to matchtrue
if at least one leaf matches the given typepublic static boolean allLeafsMatch(TreePath[] paths, Class<?> type)
paths
- the paths to testtype
- the type to matchtrue
if all leafs match the given typepublic static <T> List<T> getMatchingLeafs(TreePath[] paths, Class<T> type)
paths
- the paths to testtype
- the type to matchpublic static List<TreePath> getMatchingPaths(TreePath[] paths, Class<?> type)
paths
- the paths to testtype
- the type to matchpublic static <T> T locateCommonParent(TreePath[] paths, Class<T> type)
null
if not all of the paths
contain an element of the given type or the instances are not the same.
To illustrate the behavior let us assume that there are three item types A
,
B
and C
with instances A1
, A2
and so on.
The following table illustrates the result querying for the type B
given some
example input paths:
Paths | Result |
---|---|
A1,B1,C1 A1,B1,C2 A1,B1,C3 |
B1 |
A1,A2,B1,C1 A2,B1,C2 B1,C3 |
B1 |
B1,B1,C1 B2,B1,C2 B3,B1,C3 |
B1 |
A1,B1,C1 A1,B1,C2 A1,B1,C1 |
B1 |
A1,B1,C1 A1,B1,C2 A1,B1,B4 |
null |
A1,B1,C1 A1,B1,C2 A1,B2,C3 |
null |
A1,B1,C1 A1,B1,C2 A1,C3 |
null |
paths
- type
- Copyright © 2024 levigo holding gmbh. All rights reserved.