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

org.opentripplanner.util.CompositeComparator Maven / Gradle / Ivy

package org.opentripplanner.util;

import java.util.Comparator;


/**
 * This class take a list of comparators and turn them into one,
 * iterating over the vector passes in at construction time.
 * 

* This class implement the composite design pattern. */ public class CompositeComparator implements Comparator { private final Comparator[] compareVector; @SafeVarargs public CompositeComparator(Comparator ... compareVector) { this.compareVector = compareVector; } @Override public int compare(T o1, T o2) { int v = 0; for (Comparator c : compareVector) { v = c.compare(o1, o2); if(v != 0) { return v; } } return 0; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy