use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.
the class FieldParser method parseOnWithQuestionMark.
@VisibleForTesting
protected On parseOnWithQuestionMark(final String exp) {
final SpecialCharFieldValue specialChar = new SpecialCharFieldValue(QUESTION_MARK);
final String questionMarkExpression = exp.replace(QUESTION_MARK_STRING, EMPTY_STRING);
if (EMPTY_STRING.equals(questionMarkExpression)) {
return new On(new IntegerFieldValue(-1), specialChar, new IntegerFieldValue(-1));
} else {
throw new IllegalArgumentException(String.format("Expected: '?', found: %s", questionMarkExpression));
}
}
use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.
the class FieldParser method parseOnWithHash.
@VisibleForTesting
protected On parseOnWithHash(final String exp) {
if (!fieldConstraints.getSpecialChars().contains(HASH)) {
throw new IllegalArgumentException("Invalid expression: " + exp);
}
final SpecialCharFieldValue specialChar = new SpecialCharFieldValue(HASH);
final String[] array = exp.split(HASH_TAG);
if (array.length == 0) {
throw new IllegalArgumentException("Invalid Position of # Character!");
}
final IntegerFieldValue nth = mapToIntegerFieldValue(array[1]);
if (array[0].isEmpty()) {
throw new IllegalArgumentException("Time should be specified!");
}
return new On(mapToIntegerFieldValue(array[0]), specialChar, nth);
}
use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.
the class FieldParser method parseOnWithL.
protected On parseOnWithL(final String exp, final IntegerFieldValue daysBefore) {
final SpecialCharFieldValue specialChar = new SpecialCharFieldValue(L);
final String expression = exp.replace(L_STRING, EMPTY_STRING);
IntegerFieldValue time = new IntegerFieldValue(-1);
if (!EMPTY_STRING.equals(expression)) {
time = mapToIntegerFieldValue(expression);
}
return new On(time, specialChar, daysBefore);
}
use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.
the class EveryDayOfWeekValueGeneratorTest method setUp.
@Before
public void setUp() {
FieldConstraints constraints = FieldConstraintsBuilder.instance().createConstraintsInstance();
// every 2 days between 1-5
final CronField cronField = new CronField(CronFieldName.DAY_OF_WEEK, new Every(new Between(new IntegerFieldValue(1), new IntegerFieldValue(5)), new IntegerFieldValue(2)), constraints);
// Using monday = 1
WeekDay mondayDoWValue = new WeekDay(1, false);
// so MON-FRI/2, which should translate to MON,WED,FRI
validDow = EnumSet.of(DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY, DayOfWeek.FRIDAY);
fieldValueGenerator = new EveryDayOfWeekValueGenerator(cronField, year, month, mondayDoWValue);
}
use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.
the class EveryFieldValueGeneratorTest method setUp.
@Before
public void setUp() {
constraints = FieldConstraintsBuilder.instance().createConstraintsInstance();
fieldValueGenerator = new EveryFieldValueGenerator(new CronField(CronFieldName.HOUR, new Every(new IntegerFieldValue(TIME)), constraints));
}
Aggregations