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 class
Exception thrown when a cycle was detectedstatic class
Exception 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> T
Call a control flow asCallable
static void
clear()
Forcibly clear the protector.static int
depth()
Returns depth of current traversal.static void
Enter a control flow that is not to be traversed again deeper.static void
Leave a control flow again.static void
Run a control flowprotected static String
static <T> T
Call 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.
-