org.simpleflatmapper.map.fieldmapper.FieldMapperGetterWithConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sfm-map Show documentation
Show all versions of sfm-map Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
package org.simpleflatmapper.map.fieldmapper;
import org.simpleflatmapper.converter.Context;
import org.simpleflatmapper.converter.ContextualConverter;
import org.simpleflatmapper.map.getter.ContextualGetter;
import static org.simpleflatmapper.util.Asserts.requireNonNull;
public class FieldMapperGetterWithConverter implements ContextualGetter {
private final ContextualConverter super I, ? extends P> converter;
private final ContextualGetter super T, ? extends I> getter;
public FieldMapperGetterWithConverter(ContextualConverter super I, ? extends P > converter, ContextualGetter super T, ? extends I> getter) {
this.converter = requireNonNull("converter", converter);;
this.getter = requireNonNull("getter", getter);;
}
@Override
public P get(T target, Context context) throws Exception {
I in = getter.get(target, context);
return converter.convert(in, context);
}
}