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.Mapper;
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.StaticMapperEnumarable;
import org.simpleflatmapper.util.Enumarable;
import org.simpleflatmapper.util.UnaryFactory;

public class StaticSetRowMapper extends AbstractEnumarableMapper implements SetRowMapper {

	private final Mapper mapper;
	private final MappingContextFactory mappingContextFactory;
	private final UnaryFactory> enumarableFactory;

	public StaticSetRowMapper(final Mapper mapper,
							  final ConsumerErrorHandler errorHandler,
							  final MappingContextFactory mappingContextFactory,
							  UnaryFactory> enumarableFactory) {
		super(errorHandler);
		this.mapper = mapper;
		this.mappingContextFactory = mappingContextFactory;
		this.enumarableFactory = enumarableFactory;
	}

	@Override
	public final T map(ROW rs) throws MappingException {
		return mapper.map(rs);
	}

	@Override
	public final T map(ROW rs, MappingContext context) throws MappingException {
		return mapper.map(rs, context);
	}

	@Override
	public final void mapTo(ROW rs, T target, MappingContext context) throws Exception {
		mapper.mapTo(rs, target, context);
	}

	@Override
	public String toString() {
		return "StaticSetRowMapper{" + mapper + '}';
	}

	@Override
	protected final Enumarable newEnumarableOfT(SET source) throws E {
		return new StaticMapperEnumarable(mapper, mappingContextFactory.newContext(), enumarableFactory.newInstance(source));
	}

	protected MappingContextFactory getMappingContextFactory() {
		return mappingContextFactory;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy