Class CountDownScheduler
java.lang.Object
callofproject.dev.authentication.service.CountDownScheduler
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
ConstructorsModifierConstructorDescriptionprotected
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 TypeMethodDescriptionfinal void
cancel()
Cancels the countdown scheduler.protected abstract void
onFinish()
Callback method called when the countdown finishes.protected abstract void
onTick
(long millisUntilFinished) Callback method called on each tick of the countdown.final CountDownScheduler
start()
Starts the countdown scheduler.
-
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
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
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
Callback method called when the countdown finishes.- Throws:
Exception
- Any exception that may occur during processing.
-
start
Starts the countdown scheduler.- Returns:
- The CountDownScheduler instance for method chaining.
-
cancel
public final void cancel()Cancels the countdown scheduler.
-