com.levigo.util.swing.flextree
Class FlexTreeUtils

java.lang.Object
  extended by com.levigo.util.swing.flextree.FlexTreeUtils

public class FlexTreeUtils
extends Object


Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

locateLast

public 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). If no object of the specified type exists, null is returned.


someLeafsMatch

public static boolean someLeafsMatch(TreePath[] paths,
                                     Class<?> type)
Return whether at least one leaf (last path component) of the given paths matches the given type.

Parameters:
paths - the paths to test
type - the type to match
Returns:
true if at least one leaf matches the given type

allLeafsMatch

public static boolean allLeafsMatch(TreePath[] paths,
                                    Class<?> type)
Return whether all leafs (last path components) of the given paths match the given type.

Parameters:
paths - the paths to test
type - the type to match
Returns:
true if all leafs match the given type

getMatchingLeafs

public 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.

Parameters:
paths - the paths to test
type - the type to match
Returns:
the (possibly empty) list of matching leaf items

getMatchingPaths

public 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.

Parameters:
paths - the paths to test
type - the type to match
Returns:
the (possibly empty) list of matching paths

locateCommonParent

public static <T> T locateCommonParent(TreePath[] paths,
                                       Class<T> type)
Locate a common element of the given type within the given paths. This only considers the last element of the given type within the paths. Return 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:
Example query results
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

Parameters:
paths -
type -
Returns:


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.