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

org.sfm.map.impl.AbstractMapperImpl 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: 1.10.3
Show newest version
package org.sfm.map.impl;

import org.sfm.map.Mapper;
import org.sfm.map.MappingException;
import org.sfm.reflect.Instantiator;

public abstract class AbstractMapperImpl implements Mapper {
	
	private final Instantiator instantiator;
	
	public AbstractMapperImpl(final Instantiator instantiator) {
		this.instantiator = instantiator;
	}

	@Override
	public final T map(final S source) throws MappingException {
		try {
			final T target = instantiator.newInstance(source);
			mapFields(source, target);
			return target;
		} catch(Exception e) {
			throw new MappingException(e.getMessage(), e);
		}
	}

	protected abstract void mapFields(final S source, final T target) throws Exception;
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy