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 uses
C - the type of context interface the entity's attributes are given
AS - the type of attribute set the entity owns
ASL - 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 Details

    • Entity

      protected Entity(String name, List<AS> attributeSetList)
      Constructs a new entity with the specified name and attribute sets.
      Parameters:
      name - the name of the entity, used to identify it within the model
      attributeSetList - the attribute sets the entity will own
  • Method Details

    • context

      public SC context()
      Returns the simulation context this entity uses.
      Returns:
      the entity's simulation context, or null if it has not yet been created
    • name

      public String 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

      public AS getAttributeSet(int attributeSetIndex)
      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

      public AS getAttributeSet(String attributeSetName)
      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

      public EntityLog<SC,C,AS,ASL> getLog()
      Returns the log of this entity's attribute values.
      Returns:
      a new EntityLog instance 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

      public abstract ReadOnlyEntity<SC,C,AS,ASL> getAsImmutable()
      Creates and returns an immutable version of this entity.
      Returns:
      the new ReadOnlyEntity instance