Class TimeTriggerBuilder
- java.lang.Object
-
- com.inet.taskplanner.server.api.trigger.TimeTriggerBuilder
-
public class TimeTriggerBuilder extends java.lang.Object
This can be used to easily createTimeTrigger
definition
.Example usage:
TaskDefinition task = new TaskDefinition( "mytask" ); //from tomorrow on each workday at 8:30 TriggerDefinition timeTrigger = new TimeTriggerBuilder().withStartDate( ZonedDateTime.now().plusDays( 1 ) ).withHourAndMinute( 8, 30 ).withRepeating( RepeatInterval.WORKDAYS ).create(); task.addTrigger( timeTrigger ); // .. add jobs and actions ... TaskPlanner.getInstance().addTask( task );
- Since:
- taskplanner 3.0
-
-
Constructor Summary
Constructors Constructor Description TimeTriggerBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TriggerDefinition
create()
Finish the configuration of the time trigger and create aTriggerDefinition
which can be added totasks
.TimeTriggerBuilder
withHourAndMinute(int hour, int minute)
Set the hour and minute of the day when the trigger must start the task.
The hour and minute is part of the startDate, but it determines the time of the day when the task is triggered.TimeTriggerBuilder
withMonthlyDay(MonthlyDay monthlyDay)
If you have set therepeat interval
toRepeatInterval.MONTHLY
, then you can configure here on which day of the month the task must be executed.
The default value isMonthlyDay.INITIAL
, which means the day from thestartDate
is used.TimeTriggerBuilder
withRepeating(RepeatInterval repeatInterval)
Set the repeating interval.TimeTriggerBuilder
withStartDate(java.time.ZonedDateTime startDateAndTime)
Set the start date and time to the given date.
-
-
-
Method Detail
-
withStartDate
public TimeTriggerBuilder withStartDate(@Nonnull java.time.ZonedDateTime startDateAndTime)
Set the start date and time to the given date.The trigger will start at this point in time or later depending on the
repeat interval
.The hour and minute of this defines on which time of the day the task will be executed for all future executions. Also with many
repeat intervals
the startDate has also an impact on future executions, like onweekly
interval it determines the day of week for all future executions.- Parameters:
startDateAndTime
- Date and time to use as start point- Returns:
- this builder instance
- Throws:
java.lang.IllegalArgumentException
- if given startDateAndTime is null.- Since:
- taskplanner 3.0
-
withHourAndMinute
public TimeTriggerBuilder withHourAndMinute(int hour, int minute) throws java.time.DateTimeException
Set the hour and minute of the day when the trigger must start the task.
The hour and minute is part of the startDate, but it determines the time of the day when the task is triggered.- Parameters:
hour
- hour of the day when to trigger (0..23)minute
- minute of the hour when to trigger (0..59)- Returns:
- this builder instance
- Throws:
java.time.DateTimeException
- if given hour or minute are invalid- Since:
- taskplanner 3.0
- See Also:
ZonedDateTime
-
withRepeating
public TimeTriggerBuilder withRepeating(@Nonnull RepeatInterval repeatInterval)
Set the repeating interval. The default value isRepeatInterval.NONE
. SeeRepeatInterval
for details aboout each interval.- Parameters:
repeatInterval
- the desired repeat interval fir this trigger- Returns:
- this builder instance
- Throws:
java.lang.IllegalArgumentException
- if given repeatInterval is null.- Since:
- taskplanner 3.0
-
withMonthlyDay
public TimeTriggerBuilder withMonthlyDay(@Nonnull MonthlyDay monthlyDay)
If you have set therepeat interval
toRepeatInterval.MONTHLY
, then you can configure here on which day of the month the task must be executed.
The default value isMonthlyDay.INITIAL
, which means the day from thestartDate
is used. For otherrepeating intervals
thanRepeatInterval.MONTHLY
this settings has no effect.- Parameters:
monthlyDay
- the day of the month when execution is desired- Returns:
- this builder instance
- Throws:
java.lang.IllegalArgumentException
- if given monthlyDay is null.- Since:
- taskplanner 3.0
- See Also:
MonthlyDay
-
create
public TriggerDefinition create()
Finish the configuration of the time trigger and create aTriggerDefinition
which can be added totasks
.- Returns:
- a new
TriggerDefinition
with settings from this builder. - Since:
- taskplanner 3.0
-
-