org.opentripplanner.util.CompositeComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
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 - 2025 Weber Informatics LLC | Privacy Policy