Interface Timer
@NonNullByDefault
public interface Timer
A timer is a handle for a block of code that is scheduled for future execution. A timer
can be canceled or rescheduled.
The script action "createTimer" returns a
Timer
instance.- Author:
- Kai Kreuzer - Initial contribution
-
Method Summary
Modifier and TypeMethodDescriptionboolean
cancel()
Cancels the timer@Nullable ZonedDateTime
Gets the scheduled exection timeboolean
Determines whether the scheduled execution has already terminated.boolean
isActive()
Determines whether the scheduled execution is yet to happen.boolean
Determines whether the timer has been cancelledboolean
Determines whether the scheduled code is currently executed.boolean
reschedule
(ZonedDateTime newTime) Reschedules a timer to a new starting time.
-
Method Details
-
cancel
boolean cancel()Cancels the timer- Returns:
- true, if cancellation was successful
-
getExecutionTime
@Nullable ZonedDateTime getExecutionTime()Gets the scheduled exection time- Returns:
- the scheduled execution time, or null if the timer was cancelled
-
isActive
boolean isActive()Determines whether the scheduled execution is yet to happen.- Returns:
- true, if the code is still scheduled to execute, false otherwise
-
isCancelled
boolean isCancelled()Determines whether the timer has been cancelled- Returns:
- true, if the timer has been cancelled, false otherwise
-
isRunning
boolean isRunning()Determines whether the scheduled code is currently executed.- Returns:
- true, if the code is being executed, false otherwise
-
hasTerminated
boolean hasTerminated()Determines whether the scheduled execution has already terminated.- Returns:
- true, if the scheduled execution has already terminated, false otherwise
-
reschedule
Reschedules a timer to a new starting time. This can also be called after a timer has terminated, which will result in another execution of the same code.- Parameters:
newTime
- the new time to execute the code- Returns:
- true, if the rescheduling was done successful
-