Package org.drasyl.behaviour
Class Behaviors
- java.lang.Object
-
- org.drasyl.behaviour.Behaviors
-
public final class Behaviors extends Object
Factories forBehavior
.Inspired by: https://doc.akka.io/docs/akka/current/typed/fsm.html
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Behaviors.EventScheduler
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Behavior
ignore()
A behavior that ignores every incoming message.static Behavior.BehaviorBuilder
receive()
static Behavior
same()
A behavior that advises the system to reuse the previous behavior.static Behavior
shutdown()
A behavior that advises the system to shutdown theDrasylNode
.static Behavior
unhandled()
A behavior that keeps the same behavior and signals that the event was not handled (event will be logged with DEBUG level).static Behavior
withScheduler(Function<Behaviors.EventScheduler,Behavior> factory)
A behavior with support for scheduled self events in a node.static Behavior
withScheduler(Function<Behaviors.EventScheduler,Behavior> factory, io.reactivex.rxjava3.core.Scheduler scheduler)
A behavior with support for scheduled self events in a node.
-
-
-
Method Detail
-
receive
public static Behavior.BehaviorBuilder receive()
-
unhandled
public static Behavior unhandled()
A behavior that keeps the same behavior and signals that the event was not handled (event will be logged with DEBUG level).
-
ignore
public static Behavior ignore()
A behavior that ignores every incoming message.
-
same
public static Behavior same()
A behavior that advises the system to reuse the previous behavior. This is provided in order to avoid the allocation overhead of recreating the current behavior where that is not necessary.
-
shutdown
public static Behavior shutdown()
A behavior that advises the system to shutdown theDrasylNode
. Subsequent events will be ignored.
-
withScheduler
public static Behavior withScheduler(Function<Behaviors.EventScheduler,Behavior> factory, io.reactivex.rxjava3.core.Scheduler scheduler)
A behavior with support for scheduled self events in a node.- Parameters:
factory
- function that returns the behavior that should react to scheduled self eventsscheduler
- theScheduler
to perform scheduled events on
-
withScheduler
public static Behavior withScheduler(Function<Behaviors.EventScheduler,Behavior> factory)
A behavior with support for scheduled self events in a node.- Parameters:
factory
- function that returns the behavior that should react to scheduled self events
-
-