Package com.zfabrik.work
Class CycleProtector
java.lang.Object
com.zfabrik.work.CycleProtector
A generic cycle detection utility that can be used in methods that may run into
recursive control flows.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classException thrown when a cycle was detectedstatic classException thrown when a protection stack was not cleanly resolved at the end of a work unit. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TCall a control flow asCallablestatic voidclear()Forcibly clear the protector.static intdepth()Returns depth of current traversal.static voidEnter a control flow that is not to be traversed again deeper.static voidLeave a control flow again.static voidRun a control flowprotected static Stringstatic <T> TCall a control flow as Supplier
-
Constructor Details
-
CycleProtector
public CycleProtector()
-
-
Method Details
-
enter
Enter a control flow that is not to be traversed again deeper. This may be some dependency inspection, some graph traversal, anything where a cyclic repetition is to be avoided. The node string passed identifies the control flow. -
clear
public static void clear()Forcibly clear the protector. Use with caution, if at all -
leave
Leave a control flow again. This must be the last entered. -
run
Run a control flow -
call
Call a control flow asCallable- Throws:
Exception
-
supply
Call a control flow as Supplier -
stateToString
-
depth
public static int depth()Returns depth of current traversal.
-