Search in sources :

Example 1 with FieldConstraintsBuilder

use of com.cronutils.model.field.constraint.FieldConstraintsBuilder in project cron-utils by jmrozanec.

the class BetweenDayOfWeekValueGenerator method generateCandidatesNotIncludingIntervalExtremes.

@Override
protected List<Integer> generateCandidatesNotIncludingIntervalExtremes(final int start, final int end) {
    final List<Integer> values = new ArrayList<>();
    for (Integer dayOfWeek : dowValidValues) {
        // Build a CronField representing a single day of the week
        final FieldConstraintsBuilder fcb = FieldConstraintsBuilder.instance().forField(CronFieldName.DAY_OF_WEEK);
        final CronParserField parser = new CronParserField(CronFieldName.DAY_OF_WEEK, fcb.createConstraintsInstance());
        final CronField cronField = parser.parse(dayOfWeek.toString());
        // now a generator for matching days
        final OnDayOfWeekValueGenerator odow = new OnDayOfWeekValueGenerator(cronField, year, month, mondayDoWValue);
        // get the list of matching days
        final List<Integer> candidatesList = odow.generateCandidates(start, end);
        // add them to the master list
        if (candidatesList != null) {
            values.addAll(candidatesList);
        }
    }
    Collections.sort(values);
    return values;
}
Also used : CronParserField(com.cronutils.parser.CronParserField) FieldConstraintsBuilder(com.cronutils.model.field.constraint.FieldConstraintsBuilder) CronField(com.cronutils.model.field.CronField)

Aggregations

CronField (com.cronutils.model.field.CronField)1 FieldConstraintsBuilder (com.cronutils.model.field.constraint.FieldConstraintsBuilder)1 CronParserField (com.cronutils.parser.CronParserField)1