Class Property<T,C extends Context>
java.lang.Object
modelarium.entities.attributes.AttributeBase<C>
modelarium.entities.attributes.properties.Property<T,C>
- Type Parameters:
T- the type of value this property carriesC- the type of context this property is given
- All Implemented Interfaces:
Attribute
- Direct Known Subclasses:
AgentProperty,EnvironmentProperty
public abstract sealed class Property<T,C extends Context>
extends AttributeBase<C>
permits AgentProperty<T>, EnvironmentProperty<T>
Abstract class for representing an attribute that carries a typed value.
Each tick, a property's behaviour is run and (if the property is logged) its value is recorded. Properties can
also be read and written directly through their getter and setter. This class is extended by AgentProperty
and EnvironmentProperty.
-
Method Summary
Modifier and TypeMethodDescriptionget()Returns this property's current value.protected abstract TReturns this property's current value.Creates and returns an immutable version of this attribute.voidrun()Runs this property's behaviour for the current tick.protected voidRuns this property's behaviour (does nothing by default).protected abstract voidSets this property's value.voidSets this property's value.toString()Returns the string representation of the property value.type()Returns the class of the value this property carries.Methods inherited from class modelarium.entities.attributes.AttributeBase
accessLevel, context, isLogged, name
-
Method Details
-
toString
Returns the string representation of the property value. -
type
Returns the class of the value this property carries.- Returns:
- the property's value type
-
set
Sets this property's value.- Parameters:
value- the value to set the property to
-
get
Returns this property's current value.- Returns:
- the property's value
-
run
public void run()Runs this property's behaviour for the current tick. -
run
Runs this property's behaviour (does nothing by default). Can be overridden by subclasses.- Parameters:
context- the context the property can use in its behaviour
-
set
Sets this property's value. Must be implemented by subclasses.- Parameters:
context- the context the property can use in its setter logicvalue- the value to set the property to
-
get
Returns this property's current value. Must be implemented by subclasses.- Parameters:
context- the context the property can use in its getter logic- Returns:
- the property's value
-
getAsImmutable
Creates and returns an immutable version of this attribute.- Returns:
- the new
ReadOnlyPropertyinstance
-