package backupAndRecovery;

import java.util.Comparator;

/**
 * Purpose of this class is to provide a way to compare feasibility of two
 * representations of repository hosts. Weights of repository hosts are
 * compared to determine, which of two is more feasible.
 *
 * When sorted in ascending order using this comparator, first element will be
 * most desirable. This comparator sorts in reverse order.
 *
 * @author Marcel Duris
 * @see Comparator
 */
public class RepoHostComparator implements Comparator<RepoHost> {

    public int compare(RepoHost o1, RepoHost o2) {
        if (o1.getWeight() > o2.getWeight()) {
            return -1;
        }
        if (o1.getWeight() < o2.getWeight()) {
            return 1;
        }
        return 0;
    }
}
