Skip to content

Latest commit

 

History

History
128 lines (92 loc) · 2.44 KB

README.md

File metadata and controls

128 lines (92 loc) · 2.44 KB

mpple

Build Status Build Status Coverage Status

default sample

public class Foo {

    private String firstName;
    private String lastName;

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }
}


public class FooDto {

    private String firstName;
    private String lastName;

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }
}


public interface FooMapper {

    FooDto foo(Foo foo);
}

public static void main(String[] args) {
    FooMapper fooMapper = Mpple.builder()
        .target(FooMapper.class);
    Foo foo = new Foo();
    foo.setFirstName("wonwoo");
    foo.setLastName("lee");
    assertThat(fooMapper.foo(foo).getFirstName()).isEqualTo("wonwoo");
}

for spring

@EnableMppled
public class MppleSpringConfig {

}

@Mppled
public interface FooMapper {
    FooDto foo(Foo foo);
}

@Autowired
private FooMapper fooMapper;

@Test
public void mappingTest() {
    Foo foo = new Foo();
    foo.setFirstName("wonwoo");
    foo.setLastName("lee");
    FooDto fooDto = fooMapper.foo(foo);
    assertThat(fooDto.getFirstName()).isEqualTo("wonwoo");
    assertThat(fooDto.getLastName()).isEqualTo("lee");
}

for spring boot

spring boot is default modelmapper

@Mppled
public interface FooMapper {

    FooDto foo(Foo foo);   
}

@Autowired
private FooMapper fooMapper;

@Test
public void mappingTest() {
    Foo foo = new Foo();
    foo.setFirstName("wonwoo");
    foo.setLastName("lee");
    FooDto fooDto = fooMapper.foo(foo);
    assertThat(fooDto.getFirstName()).isEqualTo("wonwoo");
    assertThat(fooDto.getLastName()).isEqualTo("lee");
}

config

TODO