Package io.github.ai4ci.abm.mechanics
Class ModifiableStateMachineContext
java.lang.Object
io.github.ai4ci.abm.mechanics.ModifiableStateMachineContext
- All Implemented Interfaces:
StateMachineContext
,Serializable
@ParametersAreNonnullByDefault
@Generated({"Modifiables.generator","StateMachineContext"})
@NotThreadSafe
public final class ModifiableStateMachineContext
extends Object
implements StateMachineContext
A modifiable implementation of the
StateMachineContext
type.
Use the create()
static factory methods to create new instances.
ModifiableStateMachineContext is not thread-safe
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionaddAllFlags
(Iterable<Boolean> elements) Adds elements toflags
list.addAllLastState
(Iterable<? extends State<?, ?, ?, ?>> elements) Adds elements tolastState
list.addFlag
(boolean element) Adds one element toflags
list.addFlags
(boolean... elements) Adds elements toflags
list.addLastState
(State<?, ?, ?, ?> element) Adds one element tolastState
list.addLastState
(State<?, ?, ?, ?>... elements) Adds elements tolastState
list.clear()
Clears the object by setting all attributes to their initial values.create()
Construct a modifiable instance ofStateMachineContext
.boolean
This instance is equal to all instances ofModifiableStateMachineContext
that have equal attribute values.from
(ModifiableStateMachineContext instance) Fill this modifiable instance with attribute values from the providedStateMachineContext
instance.from
(StateMachineContext instance) Fill this modifiable instance with attribute values from the providedStateMachineContext
instance.final State<?,
?, ?, ?> getFlags()
int
hashCode()
Computes a hash code from attributes:baselineState
,lastState
,flags
.final boolean
Returnstrue
if the required attributebaselineState
is set.final boolean
Returnstrue
if all required attributes are set, indicating that the object is initialized.setBaselineState
(State<?, ?, ?, ?> baselineState) Assigns a value to thebaselineState
attribute.Sets or replaces all elements forflags
list.setLastState
(Iterable<? extends State<?, ?, ?, ?>> elements) Sets or replaces all elements forlastState
list.toString()
Generates a string representation of thisStateMachineContext
.Reset an attribute to its initial value.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.github.ai4ci.abm.mechanics.StateMachineContext
pullBehaviour, pullFlag, pullPolicy, pushFlag, pushState
-
Method Details
-
create
Construct a modifiable instance ofStateMachineContext
.- Returns:
- A new modifiable instance
-
getBaselineState
- Specified by:
getBaselineState
in interfaceStateMachineContext
- Returns:
- value of
baselineState
attribute
-
getLastState
- Specified by:
getLastState
in interfaceStateMachineContext
- Returns:
- modifiable list
lastState
-
getFlags
- Specified by:
getFlags
in interfaceStateMachineContext
- Returns:
- modifiable list
flags
-
clear
Clears the object by setting all attributes to their initial values.- Returns:
this
for use in a chained invocation
-
from
Fill this modifiable instance with attribute values from the providedStateMachineContext
instance. Regular attribute values will be overridden, i.e. replaced with ones of an instance. Any of the instance's absent optional values will not be copied (will not override current values). Collection elements and entries will be added, not replaced.- Parameters:
instance
- The instance from which to copy values- Returns:
this
for use in a chained invocation
-
from
Fill this modifiable instance with attribute values from the providedStateMachineContext
instance. Regular attribute values will be overridden, i.e. replaced with ones of an instance. Any of the instance's absent optional values will not be copied (will not override current values). Collection elements and entries will be added, not replaced.- Parameters:
instance
- The instance from which to copy values- Returns:
this
for use in a chained invocation
-
setBaselineState
@CanIgnoreReturnValue public ModifiableStateMachineContext setBaselineState(State<?, ?, ?, ?> baselineState) Assigns a value to thebaselineState
attribute.- Parameters:
baselineState
- The value for baselineState- Returns:
this
for use in a chained invocation
-
addLastState
Adds one element tolastState
list.- Parameters:
element
- The lastState element- Returns:
this
for use in a chained invocation
-
addLastState
@SafeVarargs @CanIgnoreReturnValue public final ModifiableStateMachineContext addLastState(State<?, ?, ?, ?>... elements) Adds elements tolastState
list.- Parameters:
elements
- An array of lastState elements- Returns:
this
for use in a chained invocation
-
setLastState
@CanIgnoreReturnValue public ModifiableStateMachineContext setLastState(Iterable<? extends State<?, ?, ?, ?>> elements) Sets or replaces all elements forlastState
list.- Parameters:
elements
- An iterable of lastState elements- Returns:
this
for use in a chained invocation
-
addAllLastState
@CanIgnoreReturnValue public ModifiableStateMachineContext addAllLastState(Iterable<? extends State<?, ?, ?, ?>> elements) Adds elements tolastState
list.- Parameters:
elements
- An iterable of lastState elements- Returns:
this
for use in a chained invocation
-
addFlag
Adds one element toflags
list.- Parameters:
element
- The flags element- Returns:
this
for use in a chained invocation
-
addFlags
Adds elements toflags
list.- Parameters:
elements
- An array of flags elements- Returns:
this
for use in a chained invocation
-
setFlags
Sets or replaces all elements forflags
list.- Parameters:
elements
- An iterable of flags elements- Returns:
this
for use in a chained invocation
-
addAllFlags
Adds elements toflags
list.- Parameters:
elements
- An iterable of flags elements- Returns:
this
for use in a chained invocation
-
initialisedBaselineState
public final boolean initialisedBaselineState()Returnstrue
if the required attributebaselineState
is set.- Returns:
true
if set
-
unsetBaselineState
Reset an attribute to its initial value.- Returns:
this
for use in a chained invocation
-
isInitialized
public final boolean isInitialized()Returnstrue
if all required attributes are set, indicating that the object is initialized.- Returns:
true
if set
-
equals
This instance is equal to all instances ofModifiableStateMachineContext
that have equal attribute values. An uninitialized instance is equal only to itself. -
hashCode
public int hashCode()Computes a hash code from attributes:baselineState
,lastState
,flags
. -
toString
Generates a string representation of thisStateMachineContext
. If uninitialized, some attribute values may appear as question marks.
-