Interface Switch.StateSetCallback

All Superinterfaces:
FunctionPointer
Enclosing class:
Switch
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public static interface Switch.StateSetCallback extends FunctionPointer

Functional interface declaration of the StateSetCallback callback.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    run(boolean state)
    Emitted to change the underlying state.
    Creates a native function pointer to the upcall(MemorySegment, int) method.
    default int
    upcall(MemorySegment sourceSwitch, int state)
    The upcall method is called from native code.
  • Method Details

    • run

      boolean run(boolean state)

      Emitted to change the underlying state.

      The ::state-set signal is emitted when the user changes the switch position. The default handler calls Switch.setState(boolean) with the value of state.

      To implement delayed state change, applications can connect to this signal, initiate the change of the underlying state, and call Switch.setState(boolean) when the underlying state change is complete. The signal handler should return true to prevent the default handler from running.

    • upcall

      default int upcall(MemorySegment sourceSwitch, int state)
      The upcall method is called from native code. The parameters are marshaled and run(boolean) is executed.
    • toCallback

      default MemorySegment toCallback(Arena arena)
      Creates a native function pointer to the upcall(MemorySegment, int) method.
      Specified by:
      toCallback in interface FunctionPointer
      Parameters:
      arena - the arena in which the function pointer is allocated
      Returns:
      the native function pointer