Interface ICompoundMqttActionListener

All Superinterfaces:
org.eclipse.paho.client.mqttv3.IMqttActionListener
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 interface ICompoundMqttActionListener extends org.eclipse.paho.client.mqttv3.IMqttActionListener
An IMqttActionListener that handles both successes and failures in a single method invocation as a FunctionalInterface.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    handle(@NotNull org.eclipse.paho.client.mqttv3.IMqttToken token, @NotNull Optional<Throwable> exception)
    Handle an MQTT action.
    static @NotNull org.eclipse.paho.client.mqttv3.IMqttActionListener
    A utility method to satisfy the compiler where instances of IMqttActionListener are required by library methods, but an ICompoundMqttActionListener is used.
    default void
    onFailure(org.eclipse.paho.client.mqttv3.IMqttToken asyncActionToken, Throwable exception)
     
    default void
    onSuccess(org.eclipse.paho.client.mqttv3.IMqttToken asyncActionToken)
     
  • Method Details

    • handle

      void handle(@NotNull @NotNull org.eclipse.paho.client.mqttv3.IMqttToken token, @NotNull @NotNull Optional<Throwable> exception)
      Handle an MQTT action.

      This method will be called for both successes and failures. The token will always be available, but the exception will be present depending on whether or not the action succeeded or failed. If it failed, the optional will contain the exception that was thrown as a result of the failure.

      Parameters:
      token - the action token
      exception - an optional containing the exception that may or may not have been thrown. If the action was a success, this optional will be empty
    • onSuccess

      default void onSuccess(org.eclipse.paho.client.mqttv3.IMqttToken asyncActionToken)
      Specified by:
      onSuccess in interface org.eclipse.paho.client.mqttv3.IMqttActionListener
    • onFailure

      default void onFailure(org.eclipse.paho.client.mqttv3.IMqttToken asyncActionToken, Throwable exception)
      Specified by:
      onFailure in interface org.eclipse.paho.client.mqttv3.IMqttActionListener
    • of

      @NotNull static @NotNull org.eclipse.paho.client.mqttv3.IMqttActionListener of(@NotNull @NotNull ICompoundMqttActionListener listener)
      A utility method to satisfy the compiler where instances of IMqttActionListener are required by library methods, but an ICompoundMqttActionListener is used.

      This is sneaky :)

      Parameters:
      listener - the listener
      Returns:
      the listener as an IMqttActionListener