// By priority, then alphabetical by name
Collections.sort(reportedMethods, new Comparator<Method>() {
@Override
public int compare(Method m1, Method m2) {
CannedReportColumn m1Column = m1.getAnnotation(CannedReportColumn.class);
CannedReportColumn m2Column = m2.getAnnotation(CannedReportColumn.class);
if (m1Column == null) m1Column = new CannedReportColumn() {
public Class<? extends Annotation> annotationType() {return null;}
public int priority() { return Integer.MAX_VALUE; }
};
if (m2Column == null) m2Column = new CannedReportColumn() {
public Class<? extends Annotation> annotationType() {return null;}
public int priority() { return Integer.MAX_VALUE; }
};
// Resort to names if equal
if (m1Column.priority() == m2Column.priority())
return m1.getName().compareTo(m2.getName());
return (m1Column.priority()-m2Column.priority());
}
});
return reportedMethods;
}