Class FunctionalEnvironmentEvent

All Implemented Interfaces:
Attribute, EnvironmentAttribute

public class FunctionalEnvironmentEvent extends EnvironmentEvent
Class for representing an environment event whose logic is defined via functional interfaces.

This class is useful for defining simple event logic without requiring full subclassing, particularly when integrating with languages like Python.

  • Constructor Details

    • FunctionalEnvironmentEvent

      public FunctionalEnvironmentEvent(String name, boolean isLogged, AttributeAccessLevel accessLevel, EnvironmentEventRunFunction runLogic, EnvironmentEventIsTriggeredFunction triggerLogic)
      Constructs a new functional environment event with the specified logic functions.
      Parameters:
      name - the name of the event, used to identify it within its attribute set
      isLogged - whether the event's trigger state is logged as the model progresses
      accessLevel - the access level of the event, determining whether other entities may read it
      runLogic - the function defining the event's behaviour
      triggerLogic - the function defining the event's trigger condition
  • Method Details

    • isTriggered

      public boolean isTriggered(EnvironmentContext context)
      Determines whether this event's trigger condition is met by applying the user-provided trigger function.
      Specified by:
      isTriggered in class Event<EnvironmentContext>
      Parameters:
      context - the context the event can use in its trigger logic
      Returns:
      true if the event is triggered, false otherwise
    • run

      public void run(EnvironmentContext context)
      Runs this event's behaviour by applying the user-provided run function.
      Specified by:
      run in class Event<EnvironmentContext>
      Parameters:
      context - the context the event can use in its behaviour