Class Attributes

java.lang.Object
modelarium.attributes.Attributes
All Implemented Interfaces:
DeepCopyable<Attributes>
Direct Known Subclasses:
Events, Properties

public abstract class Attributes extends Object implements DeepCopyable<Attributes>
Abstract base class for managing a collection of Attribute instances.

This class provides the core internal structure for storing and looking up attributes by name or index. It assumes attribute names are unique within the collection.

Subclasses are responsible for populating the collection and must define the behaviour of the group during each simulation tick via the run() method.

  • Constructor Details

    • Attributes

      public Attributes()
  • Method Details

    • setAssociatedModelElement

      public void setAssociatedModelElement(ModelElement associatedModelElement)
      Associates all contained attributes with the given model element. Typically called once during initialisation.
      Parameters:
      associatedModelElement - the model element (e.g. agent or environment) to associate
    • getAssociatedModelElement

      public ModelElement getAssociatedModelElement()
      Retrieves the model element associated with attributes.
      Returns:
      the ModelElement instance
    • addAttribute

      protected void addAttribute(Attribute attribute)
      Adds or replaces an attribute in the collection. If an attribute with the same name already exists, it will be replaced at its current index; otherwise, the new attribute is appended.
      Parameters:
      attribute - the attribute to add or update
    • getAttribute

      protected Attribute getAttribute(String attributeName)
      Retrieves an attribute by its name.
      Parameters:
      attributeName - the name of the attribute to retrieve
      Returns:
      the corresponding Attribute instance
    • getAttribute

      protected Attribute getAttribute(int index)
      Retrieves an attribute by its index in the list.
      Parameters:
      index - the index position of the attribute
      Returns:
      the Attribute at the given index
    • size

      public int size()
      Returns:
      the number of attributes held by this collection
    • run

      public abstract void run()
      Defines how the entire collection of attributes should be processed during a simulation tick. Must be implemented by subclasses.