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

org.simpleflatmapper.map.impl.GetterMapper 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.map.impl;

import org.simpleflatmapper.map.FieldMapper;
import org.simpleflatmapper.map.MappingContext;
import org.simpleflatmapper.map.MappingException;
import org.simpleflatmapper.map.SourceMapper;
import org.simpleflatmapper.map.getter.ContextualGetter;
import org.simpleflatmapper.util.ErrorHelper;

public final class GetterMapper implements SourceMapper, FieldMapper {
    private final ContextualGetter getter;

    public GetterMapper(ContextualGetter getter) {
        this.getter = getter;
    }
    @Override
    public P map(S source, MappingContext context) throws MappingException {
        try {
            return getter.get(source, context);
        } catch (Exception e) {
            return ErrorHelper.rethrow(e);
        }
    }

    @Override
    public void mapTo(S source, P target, MappingContext context) throws Exception {
        // cannot map to an object
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy