1 package jdepend.framework; 2 3 import java.util.Comparator ; 4 5 13 14 public class PackageComparator implements Comparator { 15 16 private PackageComparator byWhat; 17 18 private static PackageComparator byName; 19 static { 20 byName = new PackageComparator(); 21 } 22 23 public static PackageComparator byName() { 24 return byName; 25 } 26 27 private PackageComparator() { 28 } 29 30 public PackageComparator(PackageComparator byWhat) { 31 this.byWhat = byWhat; 32 } 33 34 public PackageComparator byWhat() { 35 return byWhat; 36 } 37 38 public int compare(Object p1, Object p2) { 39 40 JavaPackage a = (JavaPackage) p1; 41 JavaPackage b = (JavaPackage) p2; 42 43 if (byWhat() == byName()) { 44 return a.getName().compareTo(b.getName()); 45 } 46 47 return 0; 48 } 49 } | Popular Tags |