Member configuration

mapFrom

Sets function that takes in source object and returns destination value.

createMap(SrcToDst, {
    bar: opt => opt.mapFrom(src => src.foo)
});

mapFromUsing

Similarly to mapFrom takes in mapping function and MappingPair which configuration will be used to map corresponding member.

createMap(SrcToDst, {
    bar: opt => opt.mapFromUsing(src => src.foo, FooToBar)
});

addTransform

Transforms value before mapping to destination.

createMap(SrcToDst, {
    bar: opt => {
        opt.mapFrom(src => src.foo);
        opt.addTransform(dest => dest + ', it was mapped!');
    }
});

condition

Called before destination value will be assigned.

createMap(SrcToDst, {
    bar: opt => {
        opt.condition(src => src.foo != null);
        opt.mapFrom(src => src.foo);
    }
});

preCondition

Called before resolving destination value and stops mapping on false.

createMap(SrcToDst, {
    bar: opt => {
        opt.preCondition(src => src.foo != null);
        opt.mapFrom(src => {
            // expensive resolution avoided with preCondition
        });
    }
});

nullSubstitute

When source member value resolves to null or undefined alternate value will be used.

createMap(SrcToDst, {
    bar: opt => {
        opt.nullSubstitute(123);
        opt.mapFrom(src => src.foo);
    }
});

ignore

Skips this member during mapping.

createMap(SrcToDst, {
    bar: opt => opt.ignore()
});

auto

Explicitly marks member for auto mapping. Can be called only on members present on both source and destination.

createMap(SrcToDst, {
    bar: opt => opt.auto()
});

Last updated