Class ReadOnlyEntity<SC extends SimulationContext,C extends Context,AS extends AttributeSet<SC,C>,ASL extends AttributeSetLog<SC>>

java.lang.Object
modelarium.entities.readonly.ReadOnlyEntity<SC,C,AS,ASL>
Type Parameters:
SC - the type of simulation context the wrapped entity uses
C - the type of context interface the wrapped entity's attributes are given
AS - the type of attribute set the wrapped entity owns
ASL - the type of attribute set log the wrapped entity produces
Direct Known Subclasses:
ReadOnlyAgent, ReadOnlyEnvironment

public abstract sealed class ReadOnlyEntity<SC extends SimulationContext,C extends Context,AS extends AttributeSet<SC,C>,ASL extends AttributeSetLog<SC>> extends Object permits ReadOnlyAgent, ReadOnlyEnvironment
Abstract class for providing a read-only view of an Entity.

This class wraps a mutable entity so that other model elements can inspect its name, attribute counts, attributes and logs without being able to modify it. It is extended by ReadOnlyAgent and ReadOnlyEnvironment.

  • Constructor Details

    • ReadOnlyEntity

      protected ReadOnlyEntity(Entity<SC,C,AS,ASL> entity)
      Constructs a new immutable entity wrapping the specified mutable entity.
      Parameters:
      entity - the mutable entity to provide a read-only view of
  • Method Details

    • getMutableEntity

      protected Entity<SC,C,AS,ASL> getMutableEntity()
      Returns the mutable entity this read-only view wraps.
      Returns:
      the wrapped entity
    • name

      public String name()
      Returns the name of the wrapped entity.
      Returns:
      the entity's name
    • attributeSetCount

      public int attributeSetCount()
      Returns the number of attribute sets the wrapped entity owns.
      Returns:
      the entity's attribute set count
    • attributeCount

      public int attributeCount()
      Returns the total number of attributes across all of the wrapped entity's attribute sets.
      Returns:
      the entity's total attribute count
    • getAttributeSet

      public abstract ReadOnlyAttributeSet<SC,C> getAttributeSet(int attributeSetIndex)
      Retrieves a read-only view of an attribute set by index. Must be implemented by subclasses.
      Parameters:
      attributeSetIndex - the index of the attribute set to retrieve
      Returns:
      a read-only view of the attribute set at the specified index
    • getAttributeSet

      public abstract ReadOnlyAttributeSet<SC,C> getAttributeSet(String attributeSetName)
      Retrieves a read-only view of an attribute set by name. Must be implemented by subclasses.
      Parameters:
      attributeSetName - the name of the attribute set to retrieve
      Returns:
      a read-only view of the attribute set with the specified name
    • getLog

      public EntityLog<SC,C,AS,ASL> getLog()
      Returns the log of the wrapped entity's attribute values.
      Returns:
      a new EntityLog instance containing the logs of the entity's attribute sets