org.sfm.map.impl.CalculateMaxIndex Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simpleFlatMapper Show documentation
Show all versions of simpleFlatMapper Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
package org.sfm.map.impl;
import org.sfm.map.ColumnDefinition;
import org.sfm.map.FieldKey;
import org.sfm.reflect.meta.ArrayElementPropertyMeta;
import org.sfm.reflect.meta.PropertyMeta;
import org.sfm.reflect.meta.SubPropertyMeta;
import org.sfm.utils.ForEachCallBack;
public final class CalculateMaxIndex, D extends ColumnDefinition> implements
ForEachCallBack> {
public int maxIndex = -1;
@SuppressWarnings("unchecked")
@Override
public void handle(PropertyMapping e) {
int currentIndex = -1;
if (e != null) {
PropertyMeta propMeta = e.getPropertyMeta();
if (propMeta.isSubProperty()) {
propMeta = ((SubPropertyMeta)propMeta).getOwnerProperty();
}
if (propMeta instanceof ArrayElementPropertyMeta, ?>) {
currentIndex = ((ArrayElementPropertyMeta, ?>) propMeta).getIndex();
}
}
maxIndex = Math.max(currentIndex, maxIndex);
}
}