jdepend.framework.PackageComparator Maven / Gradle / Ivy
package jdepend.framework;
import java.util.Comparator;
/**
* The PackageComparator
class is a Comparator
* used to compare two JavaPackage
instances for order using a
* sorting strategy.
*
* @author Mike Clark
* @author Clarkware Consulting, Inc.
*/
public class PackageComparator implements Comparator {
private PackageComparator byWhat;
private static PackageComparator byName;
static {
byName = new PackageComparator();
}
public static PackageComparator byName() {
return byName;
}
private PackageComparator() {
}
public PackageComparator(PackageComparator byWhat) {
this.byWhat = byWhat;
}
public PackageComparator byWhat() {
return byWhat;
}
public int compare(JavaPackage p1, JavaPackage p2) {
if (byWhat() == byName()) {
return p1.getName().compareTo(p2.getName());
}
return 0;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy