Class FutureEvent<T,V>
java.lang.Object
com.github.workerframework.util.rabbitmq.FutureEvent<T,V>
- Type Parameters:
T
- the type of the EventV
- the type of the returned value from the Future
- All Implemented Interfaces:
Event<T>
A more complicated Event whereby a Future is obtainable in order to block/wait upon the result of it.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionask()
protected abstract V
getEventResult
(T target) Trigger the event and return a result.final void
handleEvent
(T target) Trigger the action represented by this Event.
-
Constructor Details
-
FutureEvent
public FutureEvent()
-
-
Method Details
-
ask
- Returns:
- the Future object to interrogate the result of the Event
-
handleEvent
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 interfaceEvent<T>
- Parameters:
target
- the class to perform an action on
-
getEventResult
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
-