
org.sfm.map.impl.AbstractMapperImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simpleFlatMapper Show documentation
Show all versions of simpleFlatMapper Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
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