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 uses
C - 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 Details

    • AttributeSet

      protected AttributeSet(String name, List<Attribute> attributeList)
      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 entity
      attributeList - the attributes the set will contain, in the order they will be run
  • Method Details

    • name

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

      public Attribute get(int index)
      Retrieves a publicly accessible attribute by index.
      Parameters:
      index - the index of the attribute to retrieve
      Returns:
      the attribute at the specified index
    • get

      public Attribute get(String attributeName)
      Retrieves a publicly accessible attribute by name.
      Parameters:
      attributeName - the name of the attribute to retrieve
      Returns:
      the attribute with the specified name
    • getEvent

      public Event<C> getEvent(int eventIndex)
      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

      public Event<C> getEvent(String eventName)
      Retrieves an event by name.
      Parameters:
      eventName - the name of the event to retrieve
      Returns:
      the event with the specified name
    • getRoutine

      public Routine<C> getRoutine(int routineIndex)
      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

      public Routine<C> getRoutine(String routineName)
      Retrieves a routine by name.
      Parameters:
      routineName - the name of the routine to retrieve
      Returns:
      the routine with the specified name
    • getProperty

      public Property<?,C> getProperty(int propertyIndex)
      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

      public Property<?,C> getProperty(String propertyName)
      Retrieves a property by name.
      Parameters:
      propertyName - the name of the property to retrieve
      Returns:
      the property with the specified name
    • getLog

      public AttributeSetLog<SC> getLog()
      Returns the log recording the values of this set's logged attributes.
      Returns:
      the attribute set's AttributeSetLog instance
    • 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.