Class Latch

java.lang.Object
xbot.common.logic.Latch

public class Latch extends Object
Logical switch which consumes booleans and signals when the given value changes.
  • Constructor Details

    • Latch

      public Latch(boolean initialValue, Latch.EdgeType latchType)
      Creates a new latch.
      Parameters:
      initialValue - The initial value.
      latchType - The latch type.
    • Latch

      public Latch(boolean initialValue, Latch.EdgeType latchType, Consumer<Latch.EdgeType> callback)
      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

      public void setObserver(Consumer<Latch.EdgeType> callback)
      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.