Class ReadOnlyAttributeSet<SC extends SimulationContext,C extends Context>

java.lang.Object
modelarium.entities.attributes.sets.readonly.ReadOnlyAttributeSet<SC,C>
Type Parameters:
SC - the type of simulation context the wrapped attribute set uses
C - the type of context interface the wrapped attribute set's attributes are given
Direct Known Subclasses:
ReadOnlyAgentAttributeSet, ReadOnlyEnvironmentAttributeSet

public abstract sealed class ReadOnlyAttributeSet<SC extends SimulationContext,C extends Context> extends Object permits ReadOnlyAgentAttributeSet, ReadOnlyEnvironmentAttributeSet
Abstract class for providing a read-only view of an AttributeSet.

This class wraps a mutable attribute set so that its attributes can be inspected without the underlying set being modifiable. Retrieved attributes are deep cloned, so changes made to them do not affect the original set. It is extended by ReadOnlyAgentAttributeSet and ReadOnlyEnvironmentAttributeSet.

  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Constructs a new immutable attribute set wrapping the specified mutable attribute set.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract Attribute
    get(int index)
    Retrieves a deep clone of a publicly accessible attribute by index.
    abstract Attribute
    get(String attributeName)
    Retrieves a deep clone of a publicly accessible attribute by name.
    abstract Event<C>
    getEvent(int eventIndex)
    Retrieves a deep clone of an event by its index among the wrapped set's events.
    abstract Event<C>
    getEvent(String eventName)
    Retrieves a deep clone of an event by name.
    Returns the log recording the values of the wrapped set's logged attributes.
    abstract Property<?,C>
    getProperty(int propertyIndex)
    Retrieves a deep clone of a property by its index among the wrapped set's properties.
    abstract Property<?,C>
    getProperty(String propertyName)
    Retrieves a deep clone of a property by name.
    abstract Routine<C>
    getRoutine(int routineIndex)
    Retrieves a deep clone of a routine by its index among the wrapped set's routines.
    abstract Routine<C>
    getRoutine(String routineName)
    Retrieves a deep clone of a routine by name.
    Returns the name of the wrapped attribute set.
    int
    Returns the number of attributes in the wrapped set.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ReadOnlyAttributeSet

      protected ReadOnlyAttributeSet(AttributeSet<SC,C> attributeSet)
      Constructs a new immutable attribute set wrapping the specified mutable attribute set.
      Parameters:
      attributeSet - the mutable attribute set to provide a read-only view of
  • Method Details

    • name

      public String name()
      Returns the name of the wrapped attribute set.
      Returns:
      the attribute set's name
    • size

      public int size()
      Returns the number of attributes in the wrapped set.
      Returns:
      the attribute set's size
    • getLog

      public AttributeSetLog<SC> getLog()
      Returns the log recording the values of the wrapped set's logged attributes.
      Returns:
      the attribute set's AttributeSetLog instance
    • get

      public abstract Attribute get(int index)
      Retrieves a deep clone of a publicly accessible attribute by index. Must be implemented by subclasses.
      Parameters:
      index - the index of the attribute to retrieve
      Returns:
      a deep clone of the attribute at the specified index
    • get

      public abstract Attribute get(String attributeName)
      Retrieves a deep clone of a publicly accessible attribute by name. Must be implemented by subclasses.
      Parameters:
      attributeName - the name of the attribute to retrieve
      Returns:
      a deep clone of the attribute with the specified name
    • getEvent

      public abstract Event<C> getEvent(int eventIndex)
      Retrieves a deep clone of an event by its index among the wrapped set's events. Must be implemented by subclasses.
      Parameters:
      eventIndex - the index of the event to retrieve
      Returns:
      a deep clone of the event at the specified index
    • getEvent

      public abstract Event<C> getEvent(String eventName)
      Retrieves a deep clone of an event by name. Must be implemented by subclasses.
      Parameters:
      eventName - the name of the event to retrieve
      Returns:
      a deep clone of the event with the specified name
    • getRoutine

      public abstract Routine<C> getRoutine(int routineIndex)
      Retrieves a deep clone of a routine by its index among the wrapped set's routines. Must be implemented by subclasses.
      Parameters:
      routineIndex - the index of the routine to retrieve
      Returns:
      a deep clone of the routine at the specified index
    • getRoutine

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

      public abstract Property<?,C> getProperty(int propertyIndex)
      Retrieves a deep clone of a property by its index among the wrapped set's properties. Must be implemented by subclasses.
      Parameters:
      propertyIndex - the index of the property to retrieve
      Returns:
      a deep clone of the property at the specified index
    • getProperty

      public abstract Property<?,C> getProperty(String propertyName)
      Retrieves a deep clone of a property by name. Must be implemented by subclasses.
      Parameters:
      propertyName - the name of the property to retrieve
      Returns:
      a deep clone of the property with the specified name