Class FunctionalEnvironmentProperty<T>

Type Parameters:
T - the type of value this property carries
All Implemented Interfaces:
Attribute, EnvironmentAttribute

public class FunctionalEnvironmentProperty<T> extends EnvironmentProperty<T>
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 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 set
      isLogged - whether the property's value is logged as the model progresses
      accessLevel - the access level of the property, determining whether other entities may read it
      type - the class of the value the property carries
      getter - the function defining the property's getter logic
      setter - the function defining the property's setter logic
      runLogic - the function defining the property's behaviour
  • Method Details

    • run

      public void run(EnvironmentContext context)
      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:
      run in class Property<T,EnvironmentContext>
      Parameters:
      context - the context the property can use in its behaviour
    • set

      public void set(EnvironmentContext context, T value)
      Sets this property's value by applying the user-provided setter function and storing its result.
      Specified by:
      set in class Property<T,EnvironmentContext>
      Parameters:
      context - the context the property can use in its setter logic
      value - the value the property is being set to
    • get

      public T get(EnvironmentContext context)
      Returns this property's value by applying the user-provided getter function.
      Specified by:
      get in class Property<T,EnvironmentContext>
      Parameters:
      context - the context the property can use in its getter logic
      Returns:
      the value reported by the getter function