org.simpleflatmapper.map.mapper.JoinMapper 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.
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 super ROW> mappingContextFactory;
private final UnaryFactory> factory;
public JoinMapper(ContextualSourceFieldMapper mapper, ConsumerErrorHandler errorHandler, MappingContextFactory super ROW> 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 super ROW> getMappingContextFactory() {
return mappingContextFactory;
}
}