package org.simpleflatmapper.map.impl;

import org.simpleflatmapper.map.SourceMapper;
import org.simpleflatmapper.map.MappingContext;
import org.simpleflatmapper.map.MappingException;
import org.simpleflatmapper.reflect.Getter;
import org.simpleflatmapper.util.ErrorHelper;

public final class GetterMapper<S, P> implements SourceMapper<S, P> {
    private final Getter<? super S, P> getter;

    public GetterMapper(Getter<? super S, P> getter) {
        this.getter = getter;
    }

    @Override
    public P map(S source) throws MappingException {
        try {
            return getter.get(source);
        } catch (Exception e) {
            return ErrorHelper.rethrow(e);
        }
    }

    @Override
    public P map(S source, MappingContext<? super S> context) throws MappingException {
        try {
            return getter.get(source);
        } catch (Exception e) {
            return ErrorHelper.rethrow(e);
        }
    }
}

@@ -33,16 +33,67 @@
 .impl;%0A%0A
+import org.simpleflatmapper.map.SourceFieldMapper;%0A
 import o
@@ -370,24 +370,29 @@
 ments Source
+Field
 Mapper%3CS, P%3E
@@ -991,11 +991,128 @@
  %7D%0A    %7D
+%0A%0A    @Override%0A    public void mapTo(S source, P target, MappingContext%3C? super S%3E context) throws Exception %7B%0A    %7D
 %0A%7D%0A

make gettermapper implements empty mapTo method