public class HierarchyHelper extends Object
| Constructor and Description |
|---|
HierarchyHelper() |
| Modifier and Type | Method and Description |
|---|---|
static <K,V> List<V> |
sortHierarchy(List<V> list,
Function<V,K> getId,
Function<V,K> getParentId)
Given a list of items, sort the items such that parent items always appear
before child items.
|
static <K,V> List<V> |
sortHierarchy(List<V> list,
Function<V,K> getId,
Function<V,K> getParentId,
Comparator<V> comparator)
Given a list of items, sort the items such that parent items always appear
before child items and ensure child items are sorted.
|
public static final <K,V> List<V> sortHierarchy(List<V> list, Function<V,K> getId, Function<V,K> getParentId)
K - ID typeV - value typelist - list of itemsgetId - function to retrieve an item's IDgetParentId - function to retrieve an item's parent IDpublic static final <K,V> List<V> sortHierarchy(List<V> list, Function<V,K> getId, Function<V,K> getParentId, Comparator<V> comparator)
K - ID typeV - value typelist - list of itemsgetId - function to retrieve an item's IDgetParentId - function to retrieve an item's parent IDcomparator - sort order for items within the hierarchyCopyright © 2000–2025 MPXJ. All rights reserved.