Class AttributeSet<SC extends SimulationContext,C extends Context>
java.lang.Object
modelarium.entities.attributes.sets.AttributeSet<SC,C>
- Type Parameters:
SC- the type of simulation context this attribute set usesC- the type of context interface this attribute set's attributes are given
- Direct Known Subclasses:
AgentAttributeSet,EnvironmentAttributeSet
public abstract sealed class AttributeSet<SC extends SimulationContext,C extends Context>
extends Object
permits AgentAttributeSet, EnvironmentAttributeSet
Abstract class for containing and managing a named group of an entity's attributes.
This class is responsible for storing an entity's attributes, providing typed and access-checked retrieval of
events, routines and properties, running each attribute in order every tick, and recording the values of logged
attributes. It is extended by AgentAttributeSet and EnvironmentAttributeSet.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAttributeSet(String name, List<Attribute> attributeList) Constructs a new attribute set with the specified owner, name and attributes. -
Method Summary
Modifier and TypeMethodDescriptionget(int index) Retrieves a publicly accessible attribute by index.Retrieves a publicly accessible attribute by name.getEvent(int eventIndex) Retrieves an event by its index among this set's events.Retrieves an event by name.getLog()Returns the log recording the values of this set's logged attributes.getProperty(int propertyIndex) Retrieves a property by its index among this set's properties.getProperty(String propertyName) Retrieves a property by name.getRoutine(int routineIndex) Retrieves a routine by its index among this set's routines.getRoutine(String routineName) Retrieves a routine by name.name()Returns the name of this attribute set.voidrun()Runs each of this set's attributes in order for the current tick, recording the values of logged attributes.intsize()Returns the number of attributes in this set.
-
Constructor Details
-
AttributeSet
Constructs a new attribute set with the specified owner, name and attributes.- Parameters:
name- the name of the attribute set, used to identify it within its owning entityattributeList- the attributes the set will contain, in the order they will be run
-
-
Method Details
-
name
Returns the name of this attribute set.- Returns:
- the attribute set's name
-
size
public int size()Returns the number of attributes in this set.- Returns:
- the attribute set's size
-
get
Retrieves a publicly accessible attribute by index.- Parameters:
index- the index of the attribute to retrieve- Returns:
- the attribute at the specified index
-
get
Retrieves a publicly accessible attribute by name.- Parameters:
attributeName- the name of the attribute to retrieve- Returns:
- the attribute with the specified name
-
getEvent
Retrieves an event by its index among this set's events.- Parameters:
eventIndex- the index of the event to retrieve- Returns:
- the event at the specified index
-
getEvent
Retrieves an event by name.- Parameters:
eventName- the name of the event to retrieve- Returns:
- the event with the specified name
-
getRoutine
Retrieves a routine by its index among this set's routines.- Parameters:
routineIndex- the index of the routine to retrieve- Returns:
- the routine at the specified index
-
getRoutine
Retrieves a routine by name.- Parameters:
routineName- the name of the routine to retrieve- Returns:
- the routine with the specified name
-
getProperty
Retrieves a property by its index among this set's properties.- Parameters:
propertyIndex- the index of the property to retrieve- Returns:
- the property at the specified index
-
getProperty
Retrieves a property by name.- Parameters:
propertyName- the name of the property to retrieve- Returns:
- the property with the specified name
-
getLog
Returns the log recording the values of this set's logged attributes.- Returns:
- the attribute set's
AttributeSetLoginstance
-
run
public void run()Runs each of this set's attributes in order for the current tick, recording the values of logged attributes.Events are only run if triggered, with the trigger state logged; properties are run and their value logged; routines are simply run.
-