Package xbot.common.logic
Class Latch
java.lang.Object
xbot.common.logic.Latch
Logical switch which consumes booleans and signals when the given value
changes.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionLatch(boolean initialValue, Latch.EdgeType latchType) Creates a new latch.Latch(boolean initialValue, Latch.EdgeType latchType, Consumer<Latch.EdgeType> callback) Creates a new latch with a callback. -
Method Summary
Modifier and TypeMethodDescriptionvoidsetObserver(Consumer<Latch.EdgeType> callback) Set the callback to trigger on changes.voidsetValue(boolean newValue) Set the new value of the latch, triggering the callback if the value changes.
-
Constructor Details
-
Latch
Creates a new latch.- Parameters:
initialValue- The initial value.latchType- The latch type.
-
Latch
Creates a new latch with a callback.- Parameters:
initialValue- The initial value.latchType- The latch type.callback- The callback to trigger on changes.
-
-
Method Details
-
setObserver
Set the callback to trigger on changes.- Parameters:
callback- The callback to trigger on changes.
-
setValue
public void setValue(boolean newValue) Set the new value of the latch, triggering the callback if the value changes.- Parameters:
newValue- The new value to latch.
-