Class FunctionalEvent

java.lang.Object
modelarium.attributes.Attribute
modelarium.attributes.Event
modelarium.attributes.functional.FunctionalEvent
All Implemented Interfaces:
Serializable, DeepCopyable<Attribute>

public class FunctionalEvent extends Event
An event whose logic is defined via functional interfaces.

Useful for defining simple event logic without requiring full subclassing, particularly when integrating with languages like Python.

See Also:
  • Constructor Details

    • FunctionalEvent

      public FunctionalEvent(String name, boolean isRecorded, EventRunFunction runLogic, EventIsTriggeredFunction triggerLogic)
      Constructs a functional event with the given name, recording flag, and behaviour.
      Parameters:
      name - the name of the event
      isRecorded - whether to record the event in output
      runLogic - logic to execute when run() is called
      triggerLogic - logic to evaluate when isTriggered() is called
  • Method Details

    • isTriggered

      public boolean isTriggered()
      Description copied from class: Event
      Indicates whether the event has been triggered during this tick.
      Specified by:
      isTriggered in class Event
      Returns:
      true if triggered
    • run

      public void run()
      Description copied from class: Event
      Runs this event's internal logic.
      Specified by:
      run in class Event
    • deepCopy

      public FunctionalEvent deepCopy()
      Specified by:
      deepCopy in interface DeepCopyable<Attribute>
      Overrides:
      deepCopy in class Event