org.simpleflatmapper.jdbc.impl.setter.ConvertDelegateIndexSetter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sfm-jdbc Show documentation
Show all versions of sfm-jdbc Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
package org.simpleflatmapper.jdbc.impl.setter;
import org.simpleflatmapper.reflect.IndexedSetter;
import org.simpleflatmapper.util.ErrorHelper;
import org.simpleflatmapper.converter.Converter;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class ConvertDelegateIndexSetter implements PreparedStatementIndexSetter {
private final IndexedSetter setter;
private final Converter super I, ? extends O> converter;
public ConvertDelegateIndexSetter(IndexedSetter setter, Converter super I, ? extends O> converter) {
this.setter = setter;
this.converter = converter;
}
@Override
public void set(PreparedStatement target, I value, int columnIndex) throws SQLException {
try {
setter.set(target, converter.convert(value), columnIndex);
} catch (Exception e) {
ErrorHelper.rethrow(e);
}
}
}