Example usage for java.util Comparator interface-usage

List of usage examples for java.util Comparator interface-usage

Introduction

In this page you can find the example usage for java.util Comparator interface-usage.

Usage

From source file Main.java

class MyNameComp implements Comparator<Empl> {

    @Override
    public int compare(Empl e1, Empl e2) {
        return e1.getName().compareTo(e2.getName());
    }

From source file org.codehaus.groovy.grails.scaffolding.SimpleDomainClassPropertyComparator.java

/**
 * Comparator used when Hibernate isn't installed.
 *
 * @author Burt Beckwith
 */
@SuppressWarnings("rawtypes")

From source file be.ge0ffrey.coursera.knapsack.domain.solver.ItemDifficultyComparator.java

public class ItemDifficultyComparator implements Comparator<Item>, Serializable {

    public int compare(Item a, Item b) {
        return new CompareToBuilder().append(a.getValuePerWeight(), b.getValuePerWeight())
                .append(a.getWeight(), b.getWeight()).append(a.getId(), b.getId()).toComparison();
    }

From source file de.weltraumschaf.groundzero.opt.commons.OptionComparator.java

/**
 * Custom comparator for defining order of options.
 *
 * Implements hard coded order of options as followed:
 * <ol>
 *  <li>{@link de.weltraumschaf.groundzero.opt.OptionDescriptor#PATH_PREFIX}</li>

From source file de.thischwa.pmcms.model.tool.PathComparator.java

/**
 * {@link Comparator} to sort deeper paths to the begin of the list. Useful get the correct order for deletion. 
 *
 * @author Thilo Schwarz
 */
public class PathComparator implements Comparator<String> {

From source file org.drools.planner.benchmark.core.ranking.SingleBenchmarkRankingComparator.java

public class SingleBenchmarkRankingComparator implements Comparator<SingleBenchmark>, Serializable {

    public int compare(SingleBenchmark a, SingleBenchmark b) {
        return new CompareToBuilder().append(a.isFailure(), b.isFailure()).append(a.getScore(), b.getScore())
                .toComparison();
    }

From source file org.optaplanner.examples.tsp.domain.solver.LatitudeVisitDifficultyComparator.java

public class LatitudeVisitDifficultyComparator implements Comparator<Visit>, Serializable {

    public int compare(Visit a, Visit b) {
        return new CompareToBuilder()
                // TODO experiment with (aLatitude - bLatitude) % 10
                .append(a.getCity().getLatitude(), b.getCity().getLatitude())

From source file org.optaplanner.examples.tsp.domain.solver.LongitudeVisitDifficultyComparator.java

public class LongitudeVisitDifficultyComparator implements Comparator<Visit>, Serializable {

    public int compare(Visit a, Visit b) {
        return new CompareToBuilder()
                // TODO experiment with (aLongitude - bLongitude) % 10
                .append(a.getCity().getLongitude(), b.getCity().getLongitude())

From source file be.ge0ffrey.coursera.faculty.domain.solver.CustomerDifficultyComparator.java

public class CustomerDifficultyComparator implements Comparator<Customer>, Serializable {

    public int compare(Customer a, Customer b) {
        return new CompareToBuilder()
                // TODO experiment with (aLatitude - bLatitude) % 10
                .append(a.getLocation().getLatitude(), b.getLocation().getLatitude())

From source file org.onebusaway.admin.comparator.InferredPhaseComparator.java

/**
 * Compares vehicles by their inferred phase nulls last
 * @author abelsare
 *
 */
public class InferredPhaseComparator implements Comparator<VehicleStatus> {