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

org.simpleflatmapper.map.mapper.JoinMapper Maven / Gradle / Ivy

Go to download

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

The newest version!
package org.simpleflatmapper.map.mapper;

import org.simpleflatmapper.map.ConsumerErrorHandler;
import org.simpleflatmapper.map.ContextualSourceFieldMapper;
import org.simpleflatmapper.map.ContextualSourceMapper;
import org.simpleflatmapper.map.SourceFieldMapper;
import org.simpleflatmapper.map.SourceMapper;
import org.simpleflatmapper.map.context.MappingContextFactory;
import org.simpleflatmapper.util.Enumerable;
import org.simpleflatmapper.util.UnaryFactory;

public class JoinMapper extends AbstractEnumerableDelegateMapper {

    private final ContextualSourceFieldMapper mapper;
    private final MappingContextFactory mappingContextFactory;
    private final UnaryFactory> factory;

    public JoinMapper(ContextualSourceFieldMapper mapper, ConsumerErrorHandler errorHandler, MappingContextFactory mappingContextFactory, UnaryFactory> factory) {
        super(errorHandler);
        this.mapper = mapper;
        this.mappingContextFactory = mappingContextFactory;
        this.factory = factory;
    }


    @Override
    protected final ContextualSourceMapper getMapper(ROW source) {
        return mapper;
    }

    @Override
    public final Enumerable enumerate(ROWS source) throws EX {
        return new JoinMapperEnumerable(mapper,  mappingContextFactory.newContext(), enumerateRows(source));
    }

    private Enumerable enumerateRows(ROWS source) {
        return factory.newInstance(source);
    }

    protected MappingContextFactory getMappingContextFactory() {
        return mappingContextFactory;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy