Package modelarium.entities.readonly
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 usesC- the type of context interface the wrapped entity's attributes are givenAS- the type of attribute set the wrapped entity ownsASL- 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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the total number of attributes across all of the wrapped entity's attribute sets.intReturns the number of attribute sets the wrapped entity owns.abstract ReadOnlyAttributeSet<SC, C> getAttributeSet(int attributeSetIndex) Retrieves a read-only view of an attribute set by index.abstract ReadOnlyAttributeSet<SC, C> getAttributeSet(String attributeSetName) Retrieves a read-only view of an attribute set by name.getLog()Returns the log of the wrapped entity's attribute values.Returns the mutable entity this read-only view wraps.name()Returns the name of the wrapped entity.
-
Constructor Details
-
ReadOnlyEntity
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
Returns the mutable entity this read-only view wraps.- Returns:
- the wrapped entity
-
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
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
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
Returns the log of the wrapped entity's attribute values.- Returns:
- a new
EntityLoginstance containing the logs of the entity's attribute sets
-