Interface Task.Builder
- All Superinterfaces:
AbstractBuilder<Task>
,Builder<Task,
,Task.Builder> CopyableBuilder<Task,
,Task.Builder> ResettableBuilder<Task,
Task.Builder>
- Enclosing interface:
Task
Task
.-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds the task.default Task.Builder
delay
(long delay, TemporalUnit unit) Sets the delay before the task runs.default Task.Builder
Sets the delay before the task runs.Sets the delay before the task runs.Sets the delay before the task runs, inTicks
.default Task.Builder
Sets theRunnable
to run when this task executes.execute
(Consumer<ScheduledTask> executor) Sets the consumer that runs when this task executes.default Task.Builder
interval
(long interval, TemporalUnit unit) Sets the interval between repetitions of the task.default Task.Builder
Sets the interval between repetitions of the task.Sets the interval between repetitions of the task.Sets the interval in unit ticks between repetitions of the task.plugin
(org.spongepowered.plugin.PluginContainer plugin) Sets the plugin of the task.Methods inherited from interface org.spongepowered.api.util.CopyableBuilder
from
-
Method Details
-
execute
Sets theRunnable
to run when this task executes.- Parameters:
runnable
- The actual task to run- Returns:
- This builder, for chaining
-
execute
Sets the consumer that runs when this task executes.- Parameters:
executor
- The executor to run- Returns:
- This builder, for chaining
-
delay
Sets the delay before the task runs. This delay is an initial offset, subsequent runs (when the interval is not 0) will not be offset. By default, the delay is 0.- Parameters:
delay
- The delay in the givenTemporalUnit
unit
- The unit the delay is in- Returns:
- This builder, for chaining
- Throws:
IllegalArgumentException
- If the delay is below 0
-
delay
Sets the delay before the task runs. This delay is an initial offset, subsequent runs (when the interval is not 0) will not be offset. By default, the delay is 0.- Parameters:
delay
- The delay in the givenTimeUnit
unit
- The unit the delay is in- Returns:
- This builder, for chaining
- Throws:
IllegalArgumentException
- If the delay is below 0
-
delay
Sets the delay before the task runs, inTicks
.- Parameters:
ticks
- The delay in ticks- Returns:
- This builder, for chaining
- Throws:
IllegalArgumentException
- If the delay is below 0 or infinite
-
delay
Sets the delay before the task runs. This delay is an initial offset, subsequent runs (when the interval is not 0) will not be offset. By default, the delay is 0.- Parameters:
delay
- The delay duration- Returns:
- This builder, for chaining
- Throws:
IllegalArgumentException
- If the delay duration is below 0
-
interval
Sets the interval between repetitions of the task. The task will not repeat if the interval is 0. By default, the interval is 0.If the scheduler detects that two tasks will overlap, the 2nd task will not be started. The next time the task is due to run, the test will be made again to determine if the previous occurrence of the task is still alive (running). As long as a previous occurrence is running no new occurrences of that specific task will start, although the scheduler will never cease in trying to start it a 2nd time.
- Parameters:
interval
- The interval duration- Returns:
- This builder, for chaining
- Throws:
IllegalArgumentException
- If the interval is below 0
-
interval
Sets the interval between repetitions of the task. The task will not repeat if the interval is 0. By default, the interval is 0.If the scheduler detects that two tasks will overlap, the 2nd task will not be started. The next time the task is due to run, the test will be made again to determine if the previous occurrence of the task is still alive (running). As long as a previous occurrence is running no new occurrences of that specific task will start, although the scheduler will never cease in trying to start it a 2nd time.
- Parameters:
interval
- The interval in the givenTemporalUnit
unit
- The unit the interval is in- Returns:
- This builder, for chaining
- Throws:
IllegalArgumentException
- If the interval is below 0
-
interval
Sets the interval between repetitions of the task. The task will not repeat if the interval is 0. By default, the interval is 0.If the scheduler detects that two tasks will overlap, the 2nd task will not be started. The next time the task is due to run, the test will be made again to determine if the previous occurrence of the task is still alive (running). As long as a previous occurrence is running no new occurrences of that specific task will start, although the scheduler will never cease in trying to start it a 2nd time.
- Parameters:
interval
- The interval in the givenTimeUnit
unit
- The unit the interval is in- Returns:
- This builder, for chaining
- Throws:
IllegalArgumentException
- If the interval is below 0
-
interval
Sets the interval in unit ticks between repetitions of the task.- Parameters:
ticks
- TheTicks
between runs.- Returns:
- This builder, for chaining
- Throws:
IllegalArgumentException
- If the interval is below 0 or infinite
-
plugin
Sets the plugin of the task.- Parameters:
plugin
- The plugin instance- Returns:
- This builder, for chaining
- Throws:
IllegalArgumentException
- If the given object isn't a valid plugin
-
build
Task build()Builds the task.- Specified by:
build
in interfaceAbstractBuilder<Task>
- Returns:
- A new instance of a
Task
- Throws:
IllegalStateException
- If theexecute(Runnable)
isn't set or in the case thatplugin(PluginContainer)
isn't set.
-