org.simpleflatmapper.jdbc.property.IndexedSetterProperty 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.property;
import org.simpleflatmapper.jdbc.impl.setter.PreparedStatementSetterImpl;
import org.simpleflatmapper.map.property.SetterFactoryProperty;
import org.simpleflatmapper.map.mapper.PropertyMapping;
import org.simpleflatmapper.reflect.IndexedSetter;
import org.simpleflatmapper.reflect.Setter;
import org.simpleflatmapper.reflect.SetterFactory;
import java.lang.reflect.Type;
import java.sql.PreparedStatement;
public class IndexedSetterProperty extends SetterFactoryProperty {
private final IndexedSetter, ?> setter;
public IndexedSetterProperty(final IndexedSetter setter) {
super(new SetterFactory() {
@SuppressWarnings("unchecked")
@Override
public Setter getSetter(Object arg) {
return new PreparedStatementSetterImpl(((PropertyMapping)arg).getColumnKey().getIndex(), (IndexedSetter) setter);
}
}, PreparedStatement.class);
this.setter = setter;
}
public IndexedSetter, ?> getIndexedSetter() {
return setter;
}
@Override
public String toString() {
return "IndexedSetter{IndexedSetter}";
}
}