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

org.simpleflatmapper.map.mapper.TransformSourceFieldMapper 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.mapper;

import org.simpleflatmapper.map.FieldMapper;
import org.simpleflatmapper.map.MappingContext;
import org.simpleflatmapper.map.MappingException;
import org.simpleflatmapper.map.SourceFieldMapper;
import org.simpleflatmapper.util.Function;

public class TransformSourceFieldMapper implements SourceFieldMapper {
    
    public final SourceFieldMapper delegate;
    public final FieldMapper[] mappers;
    public final Function transform;

    public TransformSourceFieldMapper(SourceFieldMapper delegate, FieldMapper[] mappers, Function transform) {
        this.delegate = delegate;
        this.mappers = mappers;
        this.transform = transform;
    }

    @Override
    public void mapTo(S source, O target, MappingContext context) throws Exception {
        for(FieldMapper mapper : mappers) {
            mapper.mapTo(source, target, context);
        }
    }

    @Override
    public O map(S source, MappingContext context) throws MappingException {
        return transform.apply(delegate.map(source, context));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy