Class CountDownScheduler

java.lang.Object
callofproject.dev.authentication.service.CountDownScheduler

public abstract class CountDownScheduler extends Object
An abstract class for implementing a countdown scheduler with a specified interval. Subclasses should extend this class and provide implementations for the 'onTick' and 'onFinish' methods.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    CountDownScheduler(long millisInFuture, long interval)
    Creates a new CountDownScheduler with the given duration in milliseconds and interval in milliseconds.
    protected
    CountDownScheduler(long durationInFuture, long interval, TimeUnit timeUnit)
    Creates a new CountDownScheduler with the given duration, interval, and time unit.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    Cancels the countdown scheduler.
    protected abstract void
    Callback method called when the countdown finishes.
    protected abstract void
    onTick(long millisUntilFinished)
    Callback method called on each tick of the countdown.
    Starts the countdown scheduler.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CountDownScheduler

      protected CountDownScheduler(long millisInFuture, long interval)
      Creates a new CountDownScheduler with the given duration in milliseconds and interval in milliseconds.
      Parameters:
      millisInFuture - The total duration of the countdown in milliseconds.
      interval - The interval between 'onTick' callbacks in milliseconds.
    • CountDownScheduler

      protected CountDownScheduler(long durationInFuture, long interval, TimeUnit timeUnit)
      Creates a new CountDownScheduler with the given duration, interval, and time unit.
      Parameters:
      durationInFuture - The total duration of the countdown.
      interval - The interval between 'onTick' callbacks.
      timeUnit - The time unit for 'durationInFuture' and 'interval'.
  • Method Details

    • onTick

      protected abstract void onTick(long millisUntilFinished) throws Exception
      Callback method called on each tick of the countdown.
      Parameters:
      millisUntilFinished - The remaining time in milliseconds until the countdown finishes.
      Throws:
      Exception - Any exception that may occur during processing.
    • onFinish

      protected abstract void onFinish() throws Exception
      Callback method called when the countdown finishes.
      Throws:
      Exception - Any exception that may occur during processing.
    • start

      public final CountDownScheduler start()
      Starts the countdown scheduler.
      Returns:
      The CountDownScheduler instance for method chaining.
    • cancel

      public final void cancel()
      Cancels the countdown scheduler.