Class AbstractTimer

    • Field Detail

      • timerContext

        protected TimerContext timerContext
        Context used to manage this Timer; null if this Timer is not bound to a Schedule.
    • Constructor Detail

      • AbstractTimer

        public AbstractTimer()
    • Method Detail

      • timerContext

        public final TimerContext timerContext()
        Description copied from interface: Timer
        Returns the context used to manage this Timer. Returns null if this Timer is not bound to a Schedule.
        Specified by:
        timerContext in interface Timer
      • setTimerContext

        public void setTimerContext​(TimerContext timerContext)
        Description copied from interface: Timer
        Sets the context used to manage this Timer. A TimerContext is assigned when binding this Timer to a Schedule.
        Specified by:
        setTimerContext in interface Timer
      • runTimer

        public abstract void runTimer()
        Description copied from interface: Timer
        Executes scheduled logic when this Timer fires.
        Specified by:
        runTimer in interface Timer
        Specified by:
        runTimer in interface TimerFunction
      • timerWillSchedule

        public void timerWillSchedule​(long millis)
        Description copied from interface: Timer
        Lifecycle callback invoked before this Timer is scheduled for execution.
        Specified by:
        timerWillSchedule in interface Timer
      • timerDidCancel

        public void timerDidCancel()
        Description copied from interface: Timer
        Lifecycle callback invoked after this Timer is explicitly cancelled.
        Specified by:
        timerDidCancel in interface Timer
      • isScheduled

        public boolean isScheduled()
        Returns true if this timer is currently scheduled to execute. Delegates to the assigned timerContext, if set; otherwise returns false.
      • reschedule

        public void reschedule​(long millis)
        Schedules this timer to execute after millis milliseconds has elapsed. If this timer is currently scheduled, it will not execute at its previously scheduled time; it will only execute at the newly scheduled time. Delegates to the assigned timerContext.
        Throws:
        TimerException - if timerContext is null, or if millis is negative.
      • cancel

        public boolean cancel()
        Cancels this timer to prevent it from executing. Returns true if this operation caused the cancellation of this timer; returns false if this Timer was not scheduled to execute.