All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.kagkarlsson.shaded.cronutils.utils.CronFrequencyComparator Maven / Gradle / Ivy

There is a newer version: 15.0.0
Show newest version
package com.github.kagkarlsson.shaded.cronutils.utils;

import com.github.kagkarlsson.shaded.cronutils.model.Cron;
import com.github.kagkarlsson.shaded.cronutils.model.time.ExecutionTime;

import java.time.ZonedDateTime;
import java.util.Comparator;

public class CronFrequencyComparator implements Comparator {
    private final ZonedDateTime startDate;
    private final ZonedDateTime endDate;

    public CronFrequencyComparator(ZonedDateTime startDate, ZonedDateTime endDate){
        this.startDate = startDate;
        this.endDate = endDate;
    }

    @Override
    public int compare(Cron o1, Cron o2) {
        int executions1 = ExecutionTime.forCron(o1).countExecutions(startDate, endDate);
        int executions2 = ExecutionTime.forCron(o2).countExecutions(startDate, endDate);
        return executions1-executions2;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy