All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.simpleflatmapper.jdbc.property.JdbcSetterFactoryProperty Maven / Gradle / Ivy

package org.simpleflatmapper.jdbc.property;

import org.simpleflatmapper.jdbc.JdbcColumnKey;
import org.simpleflatmapper.map.mapper.PropertyMapping;
import org.simpleflatmapper.map.property.SetterFactoryProperty;
import org.simpleflatmapper.reflect.Setter;
import org.simpleflatmapper.reflect.SetterFactory;

import java.sql.PreparedStatement;
import java.sql.SQLException;

public class JdbcSetterFactoryProperty {
    public static  SetterFactoryProperty of(final PreparedStatementSetter setter) {
        SetterFactory> setterFactory = new SetterFactory>() {
            @Override
            public 

Setter getSetter(PropertyMapping arg) { final int columnIndex = arg.getColumnKey().getIndex(); return new Setter() { @Override public void set(PreparedStatement target, P value) throws Exception { setter.set(target, columnIndex, (T) value); } }; } }; return new SetterFactoryProperty(setterFactory); } public interface PreparedStatementSetter { void set(PreparedStatement ps, int i, T val) throws SQLException; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy