public abstract class AbstractActor
extends java.lang.Object
| Constructor and Description |
|---|
AbstractActor()
Creates an actor with a name equal to the current class' simple name.
|
AbstractActor(java.lang.String name)
Creates an actor with the specified name.
|
| Modifier and Type | Method and Description |
|---|---|
abstract Model |
behavior()
Override this method to provide the model for the actor's behavior.
|
protected void |
createRunnerWithBehaviorIfPresent() |
boolean |
equals(java.lang.Object obj) |
ModelRunner |
getModelRunner()
Call this method from a subclass to customize the way the actor runs the behavior.
|
java.lang.String |
getName()
Returns the name of the actor.
|
java.util.List<Step> |
getStepsOf(UseCase useCase)
Returns the steps this actor is connected with, for the specified use case.
|
java.util.Set<UseCase> |
getUseCases()
Returns the use cases this actor is associated with,
as an external user.
|
int |
hashCode() |
<T,U> java.util.Optional<U> |
reactTo(java.lang.Object message,
AbstractActor callingActor)
Same as
reactTo(Object), but with the specified actor as the calling user's role. |
<T,U> java.util.Optional<U> |
reactTo(T message)
Call this method to provide a message (i.e. command or event object) to the
actor.
|
java.lang.String |
toString() |
public AbstractActor()
public AbstractActor(java.lang.String name)
name - the name of the actorprotected void createRunnerWithBehaviorIfPresent()
public java.lang.String getName()
public java.util.Set<UseCase> getUseCases()
The actor is associated to a use case if it is connected to at least one of its steps.
Note: don't confuse this with the use cases that the actor owns as part of its behavior.
public java.util.List<Step> getStepsOf(UseCase useCase)
Note: don't confuse this with the steps that the actor owns as part of its behavior.
useCase - the use case to query for steps the actor is connected withpublic <T,U> java.util.Optional<U> reactTo(T message)
The actor will then check which steps can react. If a
single step can react, the actor will call the message handler with it. If
no step can react, the actor will either call the handler defined with
ModelRunner.handleUnhandledWith(Consumer) on the actor's model runner,
or if no such handler exists, consume the message silently.
If more than one step can react, the actor will throw an exception.
After that, the actor will trigger "autonomous system reactions"
that don't have a message class.
Note that if you provide a collection as the first and only argument, this
will be flattened to the objects in the collection, and for each object
reactTo(Object) is called.
T - the type of messageU - the return type that you as the user expects.message - the message objectMoreThanOneStepCanReact - when more than one step can reactInfiniteRepetition - when a step has an always true condition, or
there is an infinite loop.java.lang.ClassCastException - when type of the returned instance isn't UgetModelRunner(),
ModelRunner.handleUnhandledWith(Consumer),
ModelRunner.reactTo(Object)public <T,U> java.util.Optional<U> reactTo(java.lang.Object message,
AbstractActor callingActor)
reactTo(Object), but with the specified actor as the calling user's role.T - the type of messageU - the return type that you as the user expects.message - the message objectcallingActor - the actor as which to call this actor.public abstract Model behavior()
public ModelRunner getModelRunner()
public java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Object