in extensions/commons-csv/src/main/java/org/apache/batchee/csv/mapper/DefaultMapper.java [43:86]
protected DefaultMapper(final Class<T> type, final CoercingConverter coercingConverter) {
this.type = type;
this.coercingConverter = coercingConverter;
int higherIdx = -1;
Class<?> current = type;
while (current != Object.class) {
for (final Field field : type.getDeclaredFields()) {
final Csv csv = field.getAnnotation(Csv.class);
if (csv != null) {
final int pos = csv.index();
final String name = csv.name();
final boolean defaultName = Csv.DEFAULT_NAME.equals(name);
// put each field a single time to avoid to set it twice even if position and name are filled for header output
if (pos >= 0) {
if (fieldByPosition.put(pos, field) != null) {
throw new IllegalArgumentException("multiple field for index " + pos + " in " + type);
}
if (!defaultName) {
headers.put(pos, name);
}
} else if (!defaultName) {
if (fieldByName.put(name, field) != null) {
throw new IllegalArgumentException("multiple field for name '" + name + "' in " + type);
}
}
if (pos > higherIdx) {
higherIdx = pos;
}
if (!field.isAccessible()) {
field.setAccessible(true);
}
}
}
current = current.getSuperclass();
}
maxIndex = higherIdx;
}