Package modelarium.attributes
Class Attributes
java.lang.Object
modelarium.attributes.Attributes
- All Implemented Interfaces:
DeepCopyable<Attributes>
- Direct Known Subclasses:
Events,Properties
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAttribute(Attribute attribute) Adds or replaces an attribute in the collection.Retrieves the model element associated with attributes.protected AttributegetAttribute(int index) Retrieves an attribute by its index in the list.protected AttributegetAttribute(String attributeName) Retrieves an attribute by its name.abstract voidrun()Defines how the entire collection of attributes should be processed during a simulation tick.voidsetAssociatedModelElement(ModelElement associatedModelElement) Associates all contained attributes with the given model element.intsize()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface utils.DeepCopyable
deepCopy
-
Constructor Details
-
Attributes
public Attributes()
-
-
Method Details
-
setAssociatedModelElement
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
Retrieves the model element associated with attributes.- Returns:
- the
ModelElementinstance
-
addAttribute
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
Retrieves an attribute by its name.- Parameters:
attributeName- the name of the attribute to retrieve- Returns:
- the corresponding
Attributeinstance
-
getAttribute
Retrieves an attribute by its index in the list.- Parameters:
index- the index position of the attribute- Returns:
- the
Attributeat 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.
-