1 22 package org.jboss.aop.util; 23 24 import java.lang.reflect.Constructor ; 25 26 27 34 public class ConstructorComparator implements java.util.Comparator 35 { 36 private ConstructorComparator() {} 37 38 public static final java.util.Comparator INSTANCE = new ConstructorComparator(); 39 40 private int compare(Constructor m1, Constructor m2) { 41 try { 42 Class [] args1 = m1.getParameterTypes(); 43 Class [] args2 = m2.getParameterTypes(); 44 if (args1.length < args2.length) return -1; 45 if (args1.length > args2.length) return 1; 46 for (int i = 0; i < args1.length; i++) { 47 int result = args1[i].getName().compareTo( 48 args2[i].getName()); 49 if (result != 0) return result; 50 } 51 } 52 catch (Exception e) { 53 throw new RuntimeException (e); 54 } 55 throw new Error (); 57 } 58 59 public int compare(Object o1, Object o2) { 60 return compare((Constructor ) o1, (Constructor ) o2); 61 } 62 } 63 | Popular Tags |