Skip to content

Latest commit

 

History

History
44 lines (43 loc) · 921 Bytes

README.md

File metadata and controls

44 lines (43 loc) · 921 Bytes

Example

@Component
public class TestOrikaMapper implements OrikaMapper {
    @Override
    public void register(MapperFactory mapperFactory) {
        mapperFactory.classMap(X.class, Y.class)
                .field("x", "y")
                .byDefault().register();
    }
}

@RestController
public class TController {
    @Resource
    private MapperFacade facade;
    @GetMapping("/test")
    public Y test() {
        X x = new X();
        x.setX("X");
        x.setCommon("common");
        return facade.map(x, Y.class);
    }
}

via '/test' you will see

{
"common": "common",
"y": "X"
}

custom mapperFactory

@Configuration
public class Config {
    @Bean
    public MapperFactory mapperFactory() {
        //init your own factory here
        return new DefaultMapperFactory.Builder().build();
    }
}

more info of orika click here