Class AttributeBase<C extends Context>

java.lang.Object
modelarium.entities.attributes.AttributeBase<C>
Type Parameters:
C - the type of context this attribute is given
All Implemented Interfaces:
Attribute
Direct Known Subclasses:
Event, Property, Routine

public abstract non-sealed class AttributeBase<C extends Context> extends Object implements Attribute
Abstract class for providing the shared state and behaviour of all attribute types.

This class is responsible for storing an attribute's name, access level and logging flag, along with the context the attribute uses to interact with the rest of the model. It is extended by Property, Event and Routine.

  • Constructor Details

    • AttributeBase

      public AttributeBase(String name, boolean isLogged, AttributeAccessLevel accessLevel)
      Constructs a new attribute with the specified name, logging flag and access level.
      Parameters:
      name - the name of the attribute, used to identify it within its attribute set
      isLogged - whether the attribute's state is logged as the model progresses
      accessLevel - the access level of the attribute, determining whether other entities may read it
  • Method Details

    • name

      public String name()
      Returns the name of this attribute.
      Specified by:
      name in interface Attribute
      Returns:
      the attribute's name
    • isLogged

      public boolean isLogged()
      Returns whether this attribute's state is logged as the model progresses.
      Specified by:
      isLogged in interface Attribute
      Returns:
      true if the attribute is logged, false otherwise
    • context

      protected C context()
      Returns the context this attribute uses to interact with the rest of the model.
      Returns:
      the attribute's context, or null if it has not yet been set
    • accessLevel

      public AttributeAccessLevel accessLevel()
      Returns the access level of this attribute, determining whether other entities may read it.
      Specified by:
      accessLevel in interface Attribute
      Returns:
      the attribute's AttributeAccessLevel