Package com.helger.tree.util
Class TreeWithIDBuilder
- java.lang.Object
-
- com.helger.tree.util.TreeWithIDBuilder
-
@Immutable public final class TreeWithIDBuilder extends Object
Utility classes for building a tree from flat collections.- Author:
- Philip Helger
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <KEYTYPE,DATATYPE extends com.helger.commons.id.IHasID<KEYTYPE>>
DefaultTreeWithID<KEYTYPE,DATATYPE>buildTree(com.helger.commons.hierarchy.IChildrenProvider<DATATYPE> aChildrenResolver)static <KEYTYPE,DATATYPE extends com.helger.commons.id.IHasID<KEYTYPE>>
DefaultTreeWithID<KEYTYPE,DATATYPE>buildTree(DATATYPE[] aAll, com.helger.commons.hierarchy.IParentProvider<DATATYPE> aParentResolver)A generic method to build a tree of objects.static <KEYTYPE,DATATYPE extends com.helger.commons.hierarchy.IHasParent<DATATYPE> & com.helger.commons.id.IHasID<KEYTYPE>>
DefaultTreeWithID<KEYTYPE,DATATYPE>buildTree(Collection<? extends DATATYPE> aAll)A generic method to build a tree of objects.static <KEYTYPE,DATATYPE extends com.helger.commons.id.IHasID<KEYTYPE>>
DefaultTreeWithID<KEYTYPE,DATATYPE>buildTree(Collection<? extends DATATYPE> aAll, com.helger.commons.hierarchy.IParentProvider<DATATYPE> aParentResolver)A generic method to build a tree of objects.
-
-
-
Method Detail
-
buildTree
@Nonnull public static <KEYTYPE,DATATYPE extends com.helger.commons.id.IHasID<KEYTYPE>> DefaultTreeWithID<KEYTYPE,DATATYPE> buildTree(@Nonnull Collection<? extends DATATYPE> aAll, @Nonnull com.helger.commons.hierarchy.IParentProvider<DATATYPE> aParentResolver)
A generic method to build a tree of objects.- Type Parameters:
KEYTYPE- The tree key type.DATATYPE- The tree item value type.- Parameters:
aAll- A linear list of objects to build the tree from. May not benull.aParentResolver- The callback method to determine the parental object of a given object. May not benull.- Returns:
- A tree with all the objects. Never
null. - Throws:
IllegalStateException- if the hierarchy cannot be determined because an object references a parent that is not in the list!
-
buildTree
@Nonnull public static <KEYTYPE,DATATYPE extends com.helger.commons.id.IHasID<KEYTYPE>> DefaultTreeWithID<KEYTYPE,DATATYPE> buildTree(@Nonnull DATATYPE[] aAll, @Nonnull com.helger.commons.hierarchy.IParentProvider<DATATYPE> aParentResolver)
A generic method to build a tree of objects.- Type Parameters:
KEYTYPE- The tree key type.DATATYPE- The tree item value type.- Parameters:
aAll- A linear list of objects to build the tree from. May not benull.aParentResolver- The callback method to determine the parental object of a given object. May not benull.- Returns:
- A tree with all the objects. Never
null. - Throws:
IllegalStateException- if the hierarchy cannot be determined because an object references a parent that is not in the list!
-
buildTree
@Nonnull public static <KEYTYPE,DATATYPE extends com.helger.commons.hierarchy.IHasParent<DATATYPE> & com.helger.commons.id.IHasID<KEYTYPE>> DefaultTreeWithID<KEYTYPE,DATATYPE> buildTree(@Nonnull Collection<? extends DATATYPE> aAll)
A generic method to build a tree of objects.- Type Parameters:
KEYTYPE- The tree key type.DATATYPE- The tree item value type.- Parameters:
aAll- A linear list of objects to build the tree from. May not benull.- Returns:
- A tree with all the objects. Never
null. - Throws:
IllegalStateException- if the hierarchy cannot be determined because an object references a parent that is not in the list!
-
buildTree
@Nonnull public static <KEYTYPE,DATATYPE extends com.helger.commons.id.IHasID<KEYTYPE>> DefaultTreeWithID<KEYTYPE,DATATYPE> buildTree(@Nonnull com.helger.commons.hierarchy.IChildrenProvider<DATATYPE> aChildrenResolver)
-
-