Class FunctionalEnvironmentProperty<T>
java.lang.Object
modelarium.entities.attributes.AttributeBase<EnvironmentContext>
modelarium.entities.attributes.properties.Property<T,EnvironmentContext>
modelarium.entities.attributes.properties.EnvironmentProperty<T>
modelarium.entities.attributes.properties.functional.FunctionalEnvironmentProperty<T>
- Type Parameters:
T- the type of value this property carries
- All Implemented Interfaces:
Attribute,EnvironmentAttribute
Class for representing an environment property whose behaviour is defined via functional interfaces.
This class allows dynamic configuration of property behaviour, which is useful when working with external systems or when subclassing is not feasible (e.g. in Python via JPype). The property's value is stored internally and passed to each of the user-provided functions.
-
Constructor Summary
ConstructorsConstructorDescriptionFunctionalEnvironmentProperty(String name, boolean isLogged, AttributeAccessLevel accessLevel, Class<T> type, EnvironmentPropertyGetterFunction<T> getter, EnvironmentPropertySetterFunction<T> setter, EnvironmentPropertyRunFunction<T> runLogic) Constructs a new functional environment property with the specified logic functions. -
Method Summary
Modifier and TypeMethodDescriptionget(EnvironmentContext context) Returns this property's value by applying the user-provided getter function.voidrun(EnvironmentContext context) Runs this property's behaviour by applying the user-provided run function and storing its result.voidset(EnvironmentContext context, T value) Sets this property's value by applying the user-provided setter function and storing its result.Methods inherited from class modelarium.entities.attributes.properties.Property
get, getAsImmutable, run, set, toString, typeMethods inherited from class modelarium.entities.attributes.AttributeBase
accessLevel, context, isLogged, nameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface modelarium.entities.attributes.Attribute
accessLevel, getAsImmutable, isLogged, name, run
-
Constructor Details
-
FunctionalEnvironmentProperty
public FunctionalEnvironmentProperty(String name, boolean isLogged, AttributeAccessLevel accessLevel, Class<T> type, EnvironmentPropertyGetterFunction<T> getter, EnvironmentPropertySetterFunction<T> setter, EnvironmentPropertyRunFunction<T> runLogic) Constructs a new functional environment property with the specified logic functions.- Parameters:
name- the name of the property, used to identify it within its attribute setisLogged- whether the property's value is logged as the model progressesaccessLevel- the access level of the property, determining whether other entities may read ittype- the class of the value the property carriesgetter- the function defining the property's getter logicsetter- the function defining the property's setter logicrunLogic- the function defining the property's behaviour
-
-
Method Details
-
run
Runs this property's behaviour by applying the user-provided run function and storing its result.If no run function was provided, this method does nothing.
- Overrides:
runin classProperty<T,EnvironmentContext> - Parameters:
context- the context the property can use in its behaviour
-
set
Sets this property's value by applying the user-provided setter function and storing its result.- Specified by:
setin classProperty<T,EnvironmentContext> - Parameters:
context- the context the property can use in its setter logicvalue- the value the property is being set to
-
get
Returns this property's value by applying the user-provided getter function.- Specified by:
getin classProperty<T,EnvironmentContext> - Parameters:
context- the context the property can use in its getter logic- Returns:
- the value reported by the getter function
-