Class FunctionalAgentEvent
java.lang.Object
modelarium.entities.attributes.AttributeBase<AgentContext>
modelarium.entities.attributes.events.Event<AgentContext>
modelarium.entities.attributes.events.AgentEvent
modelarium.entities.attributes.events.functional.FunctionalAgentEvent
- All Implemented Interfaces:
AgentAttribute,Attribute
Class for representing an agent 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
ConstructorsConstructorDescriptionFunctionalAgentEvent(String name, boolean isLogged, AttributeAccessLevel accessLevel, AgentEventRunFunction runLogic, AgentEventIsTriggeredFunction triggerLogic) Constructs a new functional agent event with the specified logic functions. -
Method Summary
Modifier and TypeMethodDescriptionbooleanisTriggered(AgentContext context) Determines whether this event's trigger condition is met by applying the user-provided trigger function.voidrun(AgentContext 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
-
FunctionalAgentEvent
public FunctionalAgentEvent(String name, boolean isLogged, AttributeAccessLevel accessLevel, AgentEventRunFunction runLogic, AgentEventIsTriggeredFunction triggerLogic) Constructs a new functional agent 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<AgentContext>- 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<AgentContext>- Parameters:
context- the context the event can use in its behaviour
-