org.simpleflatmapper.map.mapper.ContextualMapper Maven / Gradle / Ivy
package org.simpleflatmapper.map.mapper;
import org.simpleflatmapper.map.Mapper;
import org.simpleflatmapper.map.MappingContext;
import org.simpleflatmapper.map.context.MappingContextFactory;
import org.simpleflatmapper.map.MappingException;
public class ContextualMapper implements Mapper {
private final MappingContextFactory mappingContextFactory;
private final Mapper delegate;
public ContextualMapper(Mapper delegate, MappingContextFactory mappingContextFactory) {
this.delegate = delegate;
this.mappingContextFactory = mappingContextFactory;
}
public MappingContext newMappingContext() {
return mappingContextFactory.newContext();
}
@Override
public T map(S source) throws MappingException {
return delegate.map(source, mappingContextFactory.newContext());
}
@Override
public T map(S source, MappingContext super S> context) throws MappingException {
return delegate.map(source, context);
}
@Override
public void mapTo(S source, T target, MappingContext super S> context) throws Exception {
delegate.mapTo(source, target, context);
}
@Override
public String toString() {
return "ContextualMapper{" +
"mappingContextFactory=" + mappingContextFactory +
", delegate=" + delegate +
'}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy