Interface IHierarchyVisitorCallback<DATATYPE>
-
- Type Parameters:
DATATYPE- The type of object to be iterated.
- All Superinterfaces:
ICallback
- All Known Implementing Classes:
DefaultHierarchyVisitorCallback
public interface IHierarchyVisitorCallback<DATATYPE> extends ICallback
Base interface with callbacks for visiting a hierarchy.- Author:
- Philip Helger
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidbegin()Called before the tree walking starts.default voidend()Called after the tree walking ended.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.default voidonLevelDown()Called before the tree walker descends into the next tree level.default voidonLevelUp()Called after the tree walker ascends into the previous tree level.
-
-
-
Method Detail
-
begin
default void begin()
Called before the tree walking starts.
-
getLevel
@Nonnegative int getLevel()
- Returns:
- The level of the current node within the hierarchy. Always ≥ 0. The root item has level 0.
-
onLevelDown
default void onLevelDown()
Called before the tree walker descends into the next tree level. After this callgetLevel()should return a value increased by 1.
-
onLevelUp
default void onLevelUp()
Called after the tree walker ascends into the previous tree level. After this callgetLevel()should return a value decreased by 1.
-
onItemBeforeChildren
@Nonnull EHierarchyVisitorReturn onItemBeforeChildren(DATATYPE aItem)
Called before children of the current item are visited. This method is also to be called if no children are present at all.- Parameters:
aItem- The current item. May benull.- Returns:
- A non-
nullstatus code that determines how to continue iteration.
-
onItemAfterChildren
@Nonnull EHierarchyVisitorReturn onItemAfterChildren(DATATYPE aItem)
Called 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 ifonItemBeforeChildren(Object)was called.- Parameters:
aItem- The current item. May benull.- Returns:
- A non-
nullstatus code that determines how to continue iteration.
-
end
default void end()
Called after the tree walking ended.
-
-