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 usesC- 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
ConstructorsModifierConstructorDescriptionprotectedReadOnlyAttributeSet(AttributeSet<SC, C> attributeSet) Constructs a new immutable attribute set wrapping the specified mutable attribute set. -
Method Summary
Modifier and TypeMethodDescriptionabstract Attributeget(int index) Retrieves a deep clone of a publicly accessible attribute by index.abstract AttributeRetrieves a deep clone of a publicly accessible attribute by name.getEvent(int eventIndex) Retrieves a deep clone of an event by its index among the wrapped set's events.Retrieves a deep clone of an event by name.getLog()Returns the log recording the values of the wrapped set's logged attributes.getProperty(int propertyIndex) Retrieves a deep clone of a property by its index among the wrapped set's properties.getProperty(String propertyName) Retrieves a deep clone of a property by name.getRoutine(int routineIndex) Retrieves a deep clone of a routine by its index among the wrapped set's routines.getRoutine(String routineName) Retrieves a deep clone of a routine by name.name()Returns the name of the wrapped attribute set.intsize()Returns the number of attributes in the wrapped set.
-
Constructor Details
-
ReadOnlyAttributeSet
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
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
Returns the log recording the values of the wrapped set's logged attributes.- Returns:
- the attribute set's
AttributeSetLoginstance
-
get
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
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
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
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
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
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
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
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
-