org.simpleflatmapper.map.mapper.CalculateMaxIndex Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sfm-map Show documentation
Show all versions of sfm-map Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
package org.simpleflatmapper.map.mapper;
import org.simpleflatmapper.map.FieldKey;
import org.simpleflatmapper.reflect.meta.ArrayElementPropertyMeta;
import org.simpleflatmapper.reflect.meta.PropertyMeta;
import org.simpleflatmapper.reflect.meta.SubPropertyMeta;
import org.simpleflatmapper.util.ForEachCallBack;
public final class CalculateMaxIndex> 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);
}
}