Class FunctionalEnvironmentEvent
java.lang.Object
modelarium.entities.attributes.AttributeBase<EnvironmentContext>
modelarium.entities.attributes.events.Event<EnvironmentContext>
modelarium.entities.attributes.events.EnvironmentEvent
modelarium.entities.attributes.events.functional.FunctionalEnvironmentEvent
- All Implemented Interfaces:
Attribute,EnvironmentAttribute
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 Summary
ConstructorsConstructorDescriptionFunctionalEnvironmentEvent(String name, boolean isLogged, AttributeAccessLevel accessLevel, EnvironmentEventRunFunction runLogic, EnvironmentEventIsTriggeredFunction triggerLogic) Constructs a new functional environment event with the specified logic functions. -
Method Summary
Modifier and TypeMethodDescriptionbooleanisTriggered(EnvironmentContext context) Determines whether this event's trigger condition is met by applying the user-provided trigger function.voidrun(EnvironmentContext context) Runs this event's behaviour by applying the user-provided run function.Methods inherited from class modelarium.entities.attributes.events.Event
getAsImmutable, isTriggered, run, toStringMethods 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
-
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 setisLogged- whether the event's trigger state is logged as the model progressesaccessLevel- the access level of the event, determining whether other entities may read itrunLogic- the function defining the event's behaviourtriggerLogic- the function defining the event's trigger condition
-
-
Method Details
-
isTriggered
Determines whether this event's trigger condition is met by applying the user-provided trigger function.- Specified by:
isTriggeredin classEvent<EnvironmentContext>- Parameters:
context- the context the event can use in its trigger logic- Returns:
- true if the event is triggered, false otherwise
-
run
Runs this event's behaviour by applying the user-provided run function.- Specified by:
runin classEvent<EnvironmentContext>- Parameters:
context- the context the event can use in its behaviour
-