org.sfm.utils.conv.ArrayToListConverter 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.utils.conv;
import org.sfm.reflect.Getter;
import java.sql.Array;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
public class ArrayToListConverter implements Converter> {
private final Getter elementGetter;
public ArrayToListConverter(Getter elementGetter) {
this.elementGetter = elementGetter;
}
@Override
public List convert(Array array) throws Exception {
List list = new ArrayList();
ResultSet rs = array.getResultSet();
try {
while(rs.next()) {
list.add(elementGetter.get(rs));
}
} finally {
rs.close();
}
return list;
}
}