Package com.helger.commons.hierarchy
Class ChildrenProviderSorting<CHILDTYPE>
java.lang.Object
com.helger.commons.hierarchy.ChildrenProviderSorting<CHILDTYPE>
- Type Parameters:
CHILDTYPE- The data type of the child objects.
- All Implemented Interfaces:
IChildrenProvider<CHILDTYPE>
- Direct Known Subclasses:
ChildrenProviderSortingWithID
@Immutable
public class ChildrenProviderSorting<CHILDTYPE>
extends Object
implements IChildrenProvider<CHILDTYPE>
An
The implementation wraps an existing children provider and uses and external comparator for sorting.
IChildrenProvider that returns the children in
getAllChildren(Object) sorted.The implementation wraps an existing children provider and uses and external comparator for sorting.
- Author:
- Philip Helger
-
Constructor Summary
ConstructorsConstructorDescriptionChildrenProviderSorting(IChildrenProvider<CHILDTYPE> aCP, Comparator<? super CHILDTYPE> aComparator) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionICommonsList<? extends CHILDTYPE> getAllChildren(CHILDTYPE aCurrent) Get the children of the passed object.final intgetChildCount(CHILDTYPE aCurrent) Comparator<? super CHILDTYPE> final booleanhasChildren(CHILDTYPE aCurrent) Check if an item has children.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.helger.commons.hierarchy.IChildrenProvider
hasNoChildren
-
Constructor Details
-
ChildrenProviderSorting
public ChildrenProviderSorting(@Nonnull IChildrenProvider<CHILDTYPE> aCP, @Nonnull Comparator<? super CHILDTYPE> aComparator) Constructor.- Parameters:
aCP- The children provider to be wrappedaComparator- The comparator to be used for sorting children.
-
-
Method Details
-
getChildrenProvider
-
getComparator
-
hasChildren
Description copied from interface:IChildrenProviderCheck if an item has children.- Specified by:
hasChildrenin interfaceIChildrenProvider<CHILDTYPE>- Parameters:
aCurrent- The object to determine the children of. Nonullor non-nullconstraint possible.- Returns:
trueif this item has children,falseotherwise.
-
getChildCount
- Specified by:
getChildCountin interfaceIChildrenProvider<CHILDTYPE>- Parameters:
aCurrent- The object to determine the children count of. Nonullor non-nullconstraint possible.- Returns:
- The number of contained direct children. Always ≥ 0.
-
getAllChildren
Description copied from interface:IChildrenProviderGet the children of the passed object.- Specified by:
getAllChildrenin interfaceIChildrenProvider<CHILDTYPE>- Parameters:
aCurrent- The object to determine the children of. Nonullor non-nullconstraint possible.- Returns:
- The child objects, or
nullif there are no children. Ifnullis passed, the resolver is expected to return any possible top level (root) elements. This method may NOT returnnullif the call toIChildrenProvider.hasChildren(Object)with the same object returnedtrue.
-