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

org.simpleflatmapper.jdbc.impl.SingleIndexFieldMapper Maven / Gradle / Ivy

Go to download

Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.

There is a newer version: 9.0.2
Show newest version
package org.simpleflatmapper.jdbc.impl;

import org.simpleflatmapper.converter.Context;
import org.simpleflatmapper.jdbc.MultiIndexFieldMapper;
import org.simpleflatmapper.map.setter.ContextualIndexedSetter;
import org.simpleflatmapper.reflect.Getter;

import java.sql.PreparedStatement;

public class SingleIndexFieldMapper implements MultiIndexFieldMapper {
    private final ContextualIndexedSetter setter;
    private final Getter getter;

    public SingleIndexFieldMapper(ContextualIndexedSetter setter, Getter getter) {
        this.setter = setter;
        this.getter = getter;
    }

    @Override
    public int map(PreparedStatement ps, T value, int columnIndex, Context context) throws Exception {
        setter.set(ps, getter.get(value), columnIndex + 1, context);
        return 1;
    }

    @Override
    public int getSize(T value) {
        return 1;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy