protected void sortOrderFields(SortedMap<Integer, VariableElement> sortedFields,
Collection<VariableElement> fields) {
int maxOrderNum = -1;
for (VariableElement fieldElement : fields) {
Order order = fieldElement.getAnnotation(Order.class);
if (order != null) {
maxOrderNum = Math.max(maxOrderNum, order.value());
}
}
for (VariableElement fieldDecl : fields) {
Order order = fieldDecl.getAnnotation(Order.class);
if (order != null) {
maxOrderNum = Math.max(maxOrderNum, order.value());
sortedFields.put(order.value(), fieldDecl);
} else {
sortedFields.put(++maxOrderNum, fieldDecl);
}
}
}