use of com.cronutils.model.field.expression.QuestionMark in project cron-utils by jmrozanec.
the class ValueMappingFieldExpressionVisitorTest method testVisitQuestionMark.
@Test
public void testVisitQuestionMark() {
final FieldExpression param = FieldExpression.questionMark();
final QuestionMark questionMark = (QuestionMark) param.accept(valueMappingFieldExpressionVisitor);
// always the same cause of singleton pattern
assertTrue(param == questionMark);
}
use of com.cronutils.model.field.expression.QuestionMark in project cron-utils by jmrozanec.
the class CronConstraintsFactory method ensureEitherDayOfWeekOrDayOfMonth.
public static CronConstraint ensureEitherDayOfWeekOrDayOfMonth() {
// both a day-of-week AND a day-of-month parameter should fail for QUARTZ
return new CronConstraint("Both, a day-of-week AND a day-of-month parameter, are not supported.") {
private static final long serialVersionUID = -4423693913868081656L;
@Override
public boolean validate(Cron cron) {
CronField dayOfYearField = cron.retrieve(CronFieldName.DAY_OF_YEAR);
CronField dayOfMonthField = cron.retrieve(CronFieldName.DAY_OF_MONTH);
CronField dayOfWeekField = cron.retrieve(CronFieldName.DAY_OF_WEEK);
if (dayOfYearField == null || dayOfYearField.getExpression() instanceof QuestionMark) {
if (dayOfMonthField != null && !(dayOfMonthField.getExpression() instanceof QuestionMark)) {
return dayOfWeekField != null && dayOfWeekField.getExpression() instanceof QuestionMark;
} else {
return dayOfWeekField != null && !(dayOfWeekField.getExpression() instanceof QuestionMark);
}
}
return true;
}
};
}
Aggregations