Class MessageScheduler<T extends Message>

java.lang.Object
io.openems.backend.alerting.scheduler.MessageScheduler<T>
Type Parameters:
T - type of Message

public class MessageScheduler<T extends Message> extends Object
Schedules one or more Message for type MessageScheduler to a specific time.

After the specified time is reached, the scheduler sends the Messages to their Handler and removes them from itself.

  • Constructor Details

    • MessageScheduler

      public MessageScheduler(Handler<T> handler)
  • Method Details

    • schedule

      public void schedule(T msg)
      Add message to scheduler.
      Parameters:
      msg - to add
    • remove

      public T remove(String msgId)
      Remove message from scheduler.
      Parameters:
      msgId - for message to remove
      Returns:
      the removed Message or null, if none was found
    • isScheduled

      public boolean isScheduled(Message msg)
      Get if given message is scheduled.
      Parameters:
      msg - to check for
      Returns:
      true if is scheduled
    • isScheduled

      public boolean isScheduled(Predicate<T> find)
      Get if a message fitting the Predicate is scheduled.
      Parameters:
      find - ;filter to use
      Returns:
      true if is scheduled
    • getGeneric

      public Class<T> getGeneric()
    • size

      public int size()
      Get amount of scheduled messages.
      Returns:
      size of message queue
    • handle

      public void handle(ZonedDateTime now)
      Transfer the messages due to their handler.
      Parameters:
      now - TimeStamp on call
    • isFor

      public boolean isFor(Handler<?> handler)
      Check if this MessageScheduler handles messages for given handler.
      Parameters:
      handler - to check for
      Returns:
      true if this MessageScheduler handles messages for given handler