Package modelarium.entities
Class Entity<SC extends SimulationContext,C extends Context,AS extends AttributeSet<SC,C>,ASL extends AttributeSetLog<SC>>
java.lang.Object
modelarium.entities.Entity<SC,C,AS,ASL>
- Type Parameters:
SC- the type of simulation context the entity usesC- the type of context interface the entity's attributes are givenAS- the type of attribute set the entity ownsASL- the type of attribute set log the entity produces
- Direct Known Subclasses:
Agent,Environment
public abstract sealed class Entity<SC extends SimulationContext,C extends Context,AS extends AttributeSet<SC,C>,ASL extends AttributeSetLog<SC>>
extends Object
permits Agent, Environment
Abstract class for representing an element of the model that owns attribute sets and can be run each tick.
This class is responsible for storing an entity's attribute sets, creating and holding the simulation context
the entity's attributes use, and providing access to the entity's attributes and logs. It is extended by
Agent and Environment.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the total number of attributes across all of this entity's attribute sets.intReturns the number of attribute sets this entity owns.context()Returns the simulation context this entity uses.abstract ReadOnlyEntity<SC, C, AS, ASL> Creates and returns an immutable version of this entity.getAttributeSet(int attributeSetIndex) Retrieves an attribute set by index.getAttributeSet(String attributeSetName) Retrieves an attribute set by name.getLog()Returns the log of this entity's attribute values.name()Returns the name of this entity.voidrun()Runs each of this entity's attribute sets for the current tick.
-
Constructor Details
-
Entity
Constructs a new entity with the specified name and attribute sets.- Parameters:
name- the name of the entity, used to identify it within the modelattributeSetList- the attribute sets the entity will own
-
-
Method Details
-
context
Returns the simulation context this entity uses.- Returns:
- the entity's simulation context, or null if it has not yet been created
-
name
Returns the name of this entity.- Returns:
- the entity's name
-
attributeSetCount
public int attributeSetCount()Returns the number of attribute sets this entity owns.- Returns:
- the entity's attribute set count
-
attributeCount
public int attributeCount()Returns the total number of attributes across all of this entity's attribute sets.- Returns:
- the entity's total attribute count
-
getAttributeSet
Retrieves an attribute set by index.- Parameters:
attributeSetIndex- the index of the attribute set to retrieve- Returns:
- the attribute set at the specified index
-
getAttributeSet
Retrieves an attribute set by name.- Parameters:
attributeSetName- the name of the attribute set to retrieve- Returns:
- the attribute set with the specified name
-
getLog
Returns the log of this entity's attribute values.- Returns:
- a new
EntityLoginstance containing the logs of the entity's attribute sets
-
run
public void run()Runs each of this entity's attribute sets for the current tick. -
getAsImmutable
Creates and returns an immutable version of this entity.- Returns:
- the new
ReadOnlyEntityinstance
-