Class FutureEvent<T,V>

java.lang.Object
com.github.workerframework.util.rabbitmq.FutureEvent<T,V>
Type Parameters:
T - the type of the Event
V - the type of the returned value from the Future
All Implemented Interfaces:
Event<T>

public abstract class FutureEvent<T,V> extends Object implements Event<T>
A more complicated Event whereby a Future is obtainable in order to block/wait upon the result of it.
  • Constructor Details

    • FutureEvent

      public FutureEvent()
  • Method Details

    • ask

      public CompletableFuture<V> ask()
      Returns:
      the Future object to interrogate the result of the Event
    • handleEvent

      public final void handleEvent(T target)
      Trigger the action represented by this Event. The Event will be marked as complete with the value from getEventResult(T). This can be interrogated with the CompletableFuture accessible via ask(). Any exceptions will also trigger completion of the Future with completeExceptionally.
      Specified by:
      handleEvent in interface Event<T>
      Parameters:
      target - the class to perform an action on
    • getEventResult

      protected abstract V getEventResult(T target) throws Exception
      Trigger the event and return a result.
      Parameters:
      target - the class to perform an action on
      Returns:
      a result from the triggering of the Event
      Throws:
      Exception - if the event couldn't be triggered or the result couldn't be retrieved