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.jdbc.MultiIndexFieldMapper;
import org.simpleflatmapper.reflect.Getter;
import org.simpleflatmapper.reflect.IndexedSetter;

import java.sql.PreparedStatement;

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

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy