org.simpleflatmapper.map.mapper.StaticSetRowMapper 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.mapper;
import org.simpleflatmapper.map.ContextualSourceMapper;
import org.simpleflatmapper.map.SourceMapper;
import org.simpleflatmapper.map.MappingContext;
import org.simpleflatmapper.map.MappingException;
import org.simpleflatmapper.map.ConsumerErrorHandler;
import org.simpleflatmapper.map.SetRowMapper;
import org.simpleflatmapper.map.context.MappingContextFactory;
import org.simpleflatmapper.map.impl.StaticMapperEnumerable;
import org.simpleflatmapper.util.Enumerable;
import org.simpleflatmapper.util.UnaryFactory;
public class StaticSetRowMapper extends AbstractEnumerableMapper implements SetRowMapper {
private final ContextualSourceMapper mapper;
private final MappingContextFactory super ROW> mappingContextFactory;
private final UnaryFactory> enumerableFactory;
public StaticSetRowMapper(final ContextualSourceMapper mapper,
final ConsumerErrorHandler errorHandler,
final MappingContextFactory super ROW> mappingContextFactory,
UnaryFactory> enumerableFactory) {
super(errorHandler);
this.mapper = mapper;
this.mappingContextFactory = mappingContextFactory;
this.enumerableFactory = enumerableFactory;
}
@Override
public T map(ROW source) throws MappingException {
return mapper.map(source);
}
@Override
public final T map(ROW rs, MappingContext super ROW> context) throws MappingException {
return mapper.map(rs, context);
}
@Override
public String toString() {
return "StaticSetRowMapper{" + mapper + '}';
}
@Override
public final Enumerable enumerate(SET source) throws E {
return new StaticMapperEnumerable(mapper, mappingContextFactory.newContext(), enumerableFactory.newInstance(source));
}
protected MappingContextFactory super ROW> getMappingContextFactory() {
return mappingContextFactory;
}
}