madkit.simulation.activator

## Class DateBasedDiscreteEventActivator<A extends AbstractAgent>

- java.lang.Object
- - madkit.kernel.Activator<A>
  - - madkit.simulation.activator.GenericBehaviorActivator<A>
    - - madkit.simulation.activator.DateBasedDiscreteEventActivator<A>

- All Implemented Interfaces:
    java.lang.Comparable<DateBasedDiscreteEventActivator<A>>

      public class DateBasedDiscreteEventActivator<A extends AbstractAgent>
      extends GenericBehaviorActivator<A>
      implements java.lang.Comparable<DateBasedDiscreteEventActivator<A>>

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DateBasedDiscreteEventActivator(java.lang.String community, java.lang.String group, java.lang.String role, java.lang.String theBehaviorToActivate)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `adding(java.util.List<A> agents)` Called when a list of agents joins the corresponding group and role.
    `void` | `allAgentsLeaveRole()` Makes all the agents leave the corresponding role at once.
    `int` | `compareTo(DateBasedDiscreteEventActivator<A> o)`
    `void` | `execute(java.util.List<A> agents, java.lang.Object... args)` Triggers the corresponding behavior on all the agents which are at the CGR location defined by this activator.
    `java.lang.String` | `getCommunity()` Gets the community to which this activator/probe is binded to.
    `java.util.List<A>` | `getCurrentAgentsList()` Returns a snapshot at moment t of the agents handling the group/role couple
    `java.time.Duration` | `getDefaultInterval()`
    `java.lang.String` | `getGroup()` Gets the group to which this activator/probe is binded to.
    `java.time.LocalDateTime` | `getNextActivationDate()`
    `int` | `getPriority()`
    `java.lang.String` | `getRole()` Gets the role to which this activator/probe is binded to.
    `java.util.List<A>` | `getShuffledList()` Returns a ListIterator over the agents which is shuffled
    `void` | `initialize()` Called by the MaDKit kernel when the Activator or Probe is first added.
    `void` | `killAgents()` Kills all the agents which are monitored.
    `protected void` | `removing(A agent)` This method is automatically called when an agent leaves the corresponding group and role.
    `protected void` | `removing(java.util.List<A> agents)` This method is automatically called when a list of agents has leaved the corresponding group and role.
    `void` | `setDefaultInterval(java.time.Duration defaultInterval)`
    `void` | `setNextActivationDate(java.time.LocalDateTime nextActivationDate)`
    `void` | `setPriority(int priority)`
    `int` | `size()` Returns the number of the agents handling the group/role couple
    `java.lang.String` | `toString()` returns a string containing the CGR location and the number of monitored agents.

    - ### Methods inherited from class madkit.simulation.activator.GenericBehaviorActivator

      `getBehaviorName`

    - ### Methods inherited from class madkit.kernel.Activator

      `adding, execute, findMethodOn, findMethodOnFromArgsSample, getMadkitServiceExecutor, getSimulationTime, isMulticoreModeOn, multicoreExecute, nbOfParallelTasks, useMulticore`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### DateBasedDiscreteEventActivator

          public DateBasedDiscreteEventActivator(java.lang.String community,
                                                 java.lang.String group,
                                                 java.lang.String role,
                                                 java.lang.String theBehaviorToActivate)

  - ### Method Detail

    - #### compareTo

          public int compareTo(DateBasedDiscreteEventActivator<A> o)

      Specified by:
        `compareTo` in interface `java.lang.Comparable<DateBasedDiscreteEventActivator<A extends AbstractAgent>>`

    - #### getNextActivationDate

          public java.time.LocalDateTime getNextActivationDate()

    - #### setNextActivationDate

          public void setNextActivationDate(java.time.LocalDateTime nextActivationDate)

    - #### execute

          public void execute(java.util.List<A> agents,
                              java.lang.Object... args)

      Description copied from class: `GenericBehaviorActivator`
      Triggers the corresponding behavior on all the agents which are at the CGR location defined by this activator.
      Overrides:
        `execute` in class `GenericBehaviorActivator<A extends AbstractAgent>`
      See Also:
        `Activator.execute(List, Object...)`

    - #### getPriority

          public int getPriority()

    - #### setPriority

          public void setPriority(int priority)

    - #### toString

          public java.lang.String toString()

      returns a string containing the CGR location and the number of monitored agents.
      Overrides:
        `toString` in class `Activator<A extends AbstractAgent>`
      Returns:
        a string representation of this tool.

    - #### getDefaultInterval

          public java.time.Duration getDefaultInterval()

    - #### setDefaultInterval

          public void setDefaultInterval(java.time.Duration defaultInterval)

    - #### getCommunity

          public java.lang.String getCommunity()

      Gets the community to which this activator/probe is binded to.
      Returns:
        a string representing the community's name

    - #### getGroup

          public java.lang.String getGroup()

      Gets the group to which this activator/probe is binded to.
      Returns:
        a string representing the group's name

    - #### getRole

          public java.lang.String getRole()

      Gets the role to which this activator/probe is binded to.
      Returns:
        a string representing the role's name

    - #### initialize

          public void initialize()

      Called by the MaDKit kernel when the Activator or Probe is first added. Default behavior is: `adding(getCurrentAgentsList());`

    - #### adding

          protected void adding(java.util.List<A> agents)

      Called when a list of agents joins the corresponding group and role. This method is automatically called by the MaDKit kernel when agents enter a role due to the use of `AbstractAgent.launchAgentBucket(String, int, String...)`. Override this method when you want to do some initialization on the agents that enter the group/role. Default implementation is:

           protected void adding(final List<A> agents) {
               for (A agent : agents) {
                  adding(agent);
               }
           }

      Parameters:
        `agents` - the list of agents which have been added to this group/role at once.

    - #### removing

          protected void removing(java.util.List<A> agents)

      This method is automatically called when a list of agents has leaved the corresponding group and role. This method is empty by default. Override this method when you want to do some initialization on the agents that enter the group/role. Default implementation is:

           protected void removing(final List<A> agents) {
               for (A agent : agents) {
                  removing(agent);
               }
           }

      Parameters:
        `agents` - the list of agents which have been removed from this group/role

    - #### removing

          protected void removing(A agent)

      This method is automatically called when an agent leaves the corresponding group and role. This method is empty by default. Override this method when you want to do some work when an agent leaves the group/role. Note that the role is still handled by the agent when invoked.
      Parameters:
        `agent` - the agent which is being removed from this group/role

    - #### size

          public int size()

      Returns the number of the agents handling the group/role couple
      Returns:
        the number of the agents that handle the group/role couple

    - #### getCurrentAgentsList

          public java.util.List<A> getCurrentAgentsList()

      Returns a snapshot at moment t of the agents handling the group/role couple
      Returns:
        a list view (a snapshot at moment t) of the agents that handle the group/role couple (in proper sequence)
      Since:
        MaDKit 3.0

    - #### getShuffledList

          public java.util.List<A> getShuffledList()

      Returns a ListIterator over the agents which is shuffled
      Returns:
        a ListIterator which has been previously shuffled
      Since:
        MaDKit 3.0

    - #### killAgents

          public void killAgents()

      Kills all the agents which are monitored.

    - #### allAgentsLeaveRole

          public void allAgentsLeaveRole()

      Makes all the agents leave the corresponding role at once.

Fabien Michel, Olivier Gutknecht, Jacques Ferber - September 9 2019