public class EventEngine
extends java.lang.Object
Constructor and Description |
---|
EventEngine(ScrapingSession session)
Creates the event engine
|
Modifier and Type | Method and Description |
---|---|
<T extends AbstractEventData> |
addEventCallback(EventFireTime<T> eventTime,
EventHandler<T> callback)
Add a runnable that will be executed at the given time.
|
<T extends AbstractEventData> |
addEventCallbackWithPriority(EventFireTime<T> eventTime,
EventHandler<T> callback,
int priority)
Add a runnable that will be executed at the given time and priority.
|
<T extends AbstractEventData> |
clearCallbacksForTime(EventFireTime<T> eventTime)
Clears the callbacks for the specified time
|
<T extends AbstractEventData> |
fireEvent(EventFireTime<T> eventTime,
T data)
Fires an event for the given time with the given data
|
<T extends AbstractEventData> |
fireEvent(EventFireTime<T> eventTime,
T data,
boolean throwException)
Fires an event for the given time with the given data
|
<T extends AbstractEventData> |
getAllEventHandlers(EventFireTime<T> eventTime)
Returns a list of all callbacks for a given time, in the order they would be run (immutable)
|
<T extends AbstractEventData> |
removeEventCallback(EventFireTime<T> eventTime,
EventHandler<T> callback)
Remove a runnable that will be executed at the given time
|
void |
reset()
Removes all callbacks from the event engine
|
java.lang.String |
toString() |
public EventEngine(@Nullable ScrapingSession session)
session
- The current scraping session (used for logging)@Nullable public <T extends AbstractEventData> java.lang.Object fireEvent(@NotNull EventFireTime<T> eventTime, @NotNull T data)
eventTime
- The time to fire the eventdata
- The data about the event@Nullable public <T extends AbstractEventData> java.lang.Object fireEvent(@NotNull EventFireTime<T> eventTime, @NotNull T data, boolean throwException)
eventTime
- The time to fire the eventdata
- The data about the eventthrowException
- True if exceptions should be thrown instead of logged. When thrown, future callbacks don't runpublic <T extends AbstractEventData> void addEventCallback(@NotNull EventFireTime<T> eventTime, @NotNull EventHandler<T> callback)
eventTime
- The time to execute the callbackcallback
- The callback to executepublic <T extends AbstractEventData> void addEventCallbackWithPriority(@NotNull EventFireTime<T> eventTime, @NotNull EventHandler<T> callback, int priority)
eventTime
- The time to execute the callbackcallback
- The callback to executepriority
- The priority for this callback. Lower numbers are higher priority.public <T extends AbstractEventData> boolean removeEventCallback(@NotNull EventFireTime<T> eventTime, @NotNull EventHandler<T> callback)
eventTime
- The time to execute the callbackcallback
- The callback to remove@NotNull public <T extends AbstractEventData> java.util.List<EventHandler<T>> getAllEventHandlers(@NotNull EventFireTime<T> eventTime)
eventTime
- The time to for which to get callbackspublic <T extends AbstractEventData> void clearCallbacksForTime(@NotNull EventFireTime<T> eventTime)
eventTime
- The time to clearpublic void reset()
@NotNull public java.lang.String toString()
toString
in class java.lang.Object