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

org.simpleflatmapper.map.mapper.StaticSetRowMapper 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.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 mappingContextFactory;
	private final UnaryFactory> enumerableFactory;

	public StaticSetRowMapper(final ContextualSourceMapper mapper,
							  final ConsumerErrorHandler errorHandler,
							  final MappingContextFactory 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 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 getMappingContextFactory() {
		return mappingContextFactory;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy