Class DefaultHierarchyVisitorCallback<DATATYPE>
- java.lang.Object
-
- com.helger.commons.hierarchy.visit.DefaultHierarchyVisitorCallback<DATATYPE>
-
- Type Parameters:
DATATYPE- The type of object in the hierarchy to be iterated
- All Implemented Interfaces:
ICallback,IHierarchyVisitorCallback<DATATYPE>
public class DefaultHierarchyVisitorCallback<DATATYPE> extends Object implements IHierarchyVisitorCallback<DATATYPE>
The default implementation of theIHierarchyVisitorCallbackinterface doing nothing except counting levels.- Author:
- Philip Helger
-
-
Constructor Summary
Constructors Constructor Description DefaultHierarchyVisitorCallback()DefaultHierarchyVisitorCallback(int nInitialLevel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetLevel()EHierarchyVisitorReturnonItemAfterChildren(DATATYPE aItem)Called after eventual children of the current item were visited.EHierarchyVisitorReturnonItemBeforeChildren(DATATYPE aItem)Called before children of the current item are visited.voidonLevelDown()Called before the tree walker descends into the next tree level.voidonLevelUp()Called after the tree walker ascends into the previous tree level.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.helger.commons.hierarchy.visit.IHierarchyVisitorCallback
begin, end
-
-
-
-
Method Detail
-
getLevel
@Nonnegative public int getLevel()
- Specified by:
getLevelin interfaceIHierarchyVisitorCallback<DATATYPE>- Returns:
- The level of the current node within the hierarchy. Always ≥ 0. The root item has level 0.
-
onLevelDown
@OverridingMethodsMustInvokeSuper public void onLevelDown()
Description copied from interface:IHierarchyVisitorCallbackCalled before the tree walker descends into the next tree level. After this callIHierarchyVisitorCallback.getLevel()should return a value increased by 1.- Specified by:
onLevelDownin interfaceIHierarchyVisitorCallback<DATATYPE>
-
onLevelUp
@OverridingMethodsMustInvokeSuper public void onLevelUp()
Description copied from interface:IHierarchyVisitorCallbackCalled after the tree walker ascends into the previous tree level. After this callIHierarchyVisitorCallback.getLevel()should return a value decreased by 1.- Specified by:
onLevelUpin interfaceIHierarchyVisitorCallback<DATATYPE>
-
onItemBeforeChildren
@Nonnull public EHierarchyVisitorReturn onItemBeforeChildren(DATATYPE aItem)
Description copied from interface:IHierarchyVisitorCallbackCalled before children of the current item are visited. This method is also to be called if no children are present at all.- Specified by:
onItemBeforeChildrenin interfaceIHierarchyVisitorCallback<DATATYPE>- Parameters:
aItem- The current item. May benull.- Returns:
- A non-
nullstatus code that determines how to continue iteration.
-
onItemAfterChildren
@Nonnull public EHierarchyVisitorReturn onItemAfterChildren(DATATYPE aItem)
Description copied from interface:IHierarchyVisitorCallbackCalled after eventual children of the current item were visited. This method is also to be called if no children are present at all. This method has always to be called ifIHierarchyVisitorCallback.onItemBeforeChildren(Object)was called.- Specified by:
onItemAfterChildrenin interfaceIHierarchyVisitorCallback<DATATYPE>- Parameters:
aItem- The current item. May benull.- Returns:
- A non-
nullstatus code that determines how to continue iteration.
-
-