* @param timeUnit the time unit
* @param timeInterval the time interval
* @return the simple trigger
*/
private Trigger getSimpleTrigger(TimeUnit timeUnit, int timeInterval) {
SimpleScheduleBuilder simpleScheduleBuilder = null;
simpleScheduleBuilder = SimpleScheduleBuilder.simpleSchedule();
switch (timeUnit) {
case MILLISECONDS:
simpleScheduleBuilder.withIntervalInMilliseconds(timeInterval).repeatForever();
break;
case SECONDS:
simpleScheduleBuilder.withIntervalInSeconds(timeInterval).repeatForever();
break;
case MINUTES:
simpleScheduleBuilder.withIntervalInMinutes(timeInterval).repeatForever();
break;
case HOURS:
simpleScheduleBuilder.withIntervalInHours(timeInterval).repeatForever();
break;
case DAYS:
simpleScheduleBuilder.withIntervalInHours(timeInterval * 24).repeatForever();
break;
default:
throw new RuntimeException("The " + RelativeOutputSchedule.class.getSimpleName() + " cannot handle a time unit of " + timeUnit); //default 1 sec
}
Trigger simpleTrigger = TriggerBuilder.newTrigger().withSchedule(simpleScheduleBuilder).build();