Search in sources :

Example 1 with BeanMappingBuilder

use of org.dozer.loader.api.BeanMappingBuilder in project camel by apache.

the class DozerTypeConverterDTOTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    DozerBeanMapper mapper = createCleanMapper();
    DozerTypeConverterLoader loader = new DozerTypeConverterLoader(context, mapper);
    loader.addMapping(new BeanMappingBuilder() {

        @Override
        protected void configure() {
            mapping(CustomerDTO.class, Customer.class);
        }
    });
}
Also used : DozerTestArtifactsFactory.createDtoCustomer(org.apache.camel.converter.dozer.DozerTestArtifactsFactory.createDtoCustomer) Customer(org.apache.camel.converter.dozer.model.Customer) BeanMappingBuilder(org.dozer.loader.api.BeanMappingBuilder) CustomerDTO(org.apache.camel.converter.dozer.dto.CustomerDTO) DozerBeanMapper(org.dozer.DozerBeanMapper)

Example 2 with BeanMappingBuilder

use of org.dozer.loader.api.BeanMappingBuilder in project useful-java-links by Vedenin.

the class DozerHelloWorldApi method main.

public static void main(String[] args) {
    // init mapper
    BeanMappingBuilder builder = new BeanMappingBuilder() {

        protected void configure() {
            mapping(Source.class, Destination.class).fields("message", "text");
        }
    };
    DozerBeanMapper mapper = new DozerBeanMapper();
    mapper.addMapping(builder);
    // convert
    Source source = new Source("Hello World!");
    Destination destObject = mapper.map(source, Destination.class);
    // print Hello World!
    destObject.print();
}
Also used : BeanMappingBuilder(org.dozer.loader.api.BeanMappingBuilder) DozerBeanMapper(org.dozer.DozerBeanMapper)

Aggregations

DozerBeanMapper (org.dozer.DozerBeanMapper)2 BeanMappingBuilder (org.dozer.loader.api.BeanMappingBuilder)2 DozerTestArtifactsFactory.createDtoCustomer (org.apache.camel.converter.dozer.DozerTestArtifactsFactory.createDtoCustomer)1 CustomerDTO (org.apache.camel.converter.dozer.dto.CustomerDTO)1 Customer (org.apache.camel.converter.dozer.model.Customer)1