这个内部类
final List<ExtractFileContent> extraContentsList = new ArrayList<ExtractFileContent>();
final ListComparator comparator = new ListComparator();
Collections.sort(extraContentsList, comparator);
///我在bmp项目用来比较后排序,写了一个内部类
class ListComparator implements Comparator<Object> {
public int compare(final Object o1, final Object o2) {
int flag = 0;
if (o1 instanceof ExtractFileContent) {
final ExtractFileContent efc1 = (ExtractFileContent) o1;
final ExtractFileContent efc2 = (ExtractFileContent) o2;
final String lineText1 = efc1.getLineText();
final int lineOfferInstanceId1 = getOfferInstanceId(lineText1).intValue();
final String lineText2 = efc2.getLineText();
final int lineOfferInstanceId2 = getOfferInstanceId(lineText2).intValue();
flag = lineOfferInstanceId1 - lineOfferInstanceId2;
} else if (o1 instanceof OfferInstance) {
final OfferInstance oi1 = (OfferInstance) o1;
final OfferInstance oi2 = (OfferInstance) o2;
final int sequence1 = oi1.getId().intValue();
final int sequence2 = oi2.getId().intValue();
flag = sequence1 - sequence2;
}
return flag;
}
}