public final class EventGenerator
extends java.lang.Object
Periodically repeat a fixed event or an event provided by a supplier function.
StateMachine| Constructor and Description |
|---|
EventGenerator(StateMachine machine,
java.lang.String event,
long delay)
creates a new event generator for a given event
|
EventGenerator(StateMachine machine,
java.util.function.Supplier<java.lang.String> supplier,
long delay)
creates a new event generator based off a
Supplier function. |
| Modifier and Type | Method and Description |
|---|---|
void |
start()
starts the event generator
|
void |
stop()
stops the event generator.
|
public EventGenerator(StateMachine machine, java.lang.String event, long delay)
machine - the state machine to pass the events toevent - the event to pass to the state machinedelay - the delay in milliseconds between events. this is an
approximate value and is subject to variations due to the
system thread scheduler.java.lang.NullPointerException - the machine or event is nulljava.lang.IllegalArgumentException - the delay is zero or negativepublic EventGenerator(StateMachine machine, java.util.function.Supplier<java.lang.String> supplier, long delay)
Supplier function. It
is required that the supplier function does never return
null values as null events are not supported by the
StateMachine. If the supplier ever returns a null
value the worker thread of this generator will terminate with a
NullPointerException. The instance will however ensure that it
can be restarted.machine - the state machine to pass the events tosupplier - the event supplier providing the events to pass to the state
machinedelay - the delay in milliseconds between events. this is an
approximate value and is subject to variations due to the
system thread scheduler.java.lang.NullPointerException - the machine or supplier is nulljava.lang.IllegalArgumentException - the delay is zero or negativepublic void start()
java.lang.IllegalStateException - the generator is already runningpublic void stop()
java.lang.IllegalStateException - the generator is not runningCopyright © 2018. All Rights Reserved.