Interface DigitalEventProvider<V>

Type Parameters:
V - Type of value which gets passed to event handlers.
All Superinterfaces:
EventProvider<DigitalEventListener<V>,V>, SimpleEventProvider<V>
All Known Implementing Classes:
ButtonComponent, PirMotionSensorComponent, SoundSensorComponent, TiltSensorComponent, TouchSensorComponent

public interface DigitalEventProvider<V> extends EventProvider<DigitalEventListener<V>,V>, SimpleEventProvider<V>
Generic digital event provider with default implementation for digital components. Implementing this interface in a component class provides the user with the ability to add and remove event listeners.

Transformation of raw DigitalState into target type DigitalEventProvider is made by mapDigitalState(DigitalState). The method getDigitalInput() must return the DigitalInput instance where the listener should be added.

  • Method Details

    • getDigitalInput getDigitalInput()
      Returns the Pi4J DigitalInput associated with this component.
      Pi4J DigitalInput instance
    • mapDigitalState

      V mapDigitalState( digitalState)
      Maps the Pi4J DigitalState to the target type DigitalEventProvider.
      digitalState - Pi4J digital state to map
      Mapped component state
    • addListener

      default DigitalEventListener<V> addListener(EventHandler<V> handler)
      Adds a new event listener to this component.
      Specified by:
      addListener in interface EventProvider<DigitalEventListener<V>,V>
      handler - Event handler to call
      Event listener instance
    • removeListener

      default void removeListener(DigitalEventListener<V> listener)
      Removes an existing event listener from this component.
      Specified by:
      removeListener in interface EventProvider<DigitalEventListener<V>,V>
      listener - Event listener to remove