use of org.dozer.DozerBeanMapper in project camel by apache.
the class DozerEndpoint method createDozerBeanMapper.
private DozerBeanMapper createDozerBeanMapper() throws Exception {
DozerBeanMapper answer = DozerComponent.createDozerBeanMapper(Collections.<String>emptyList());
InputStream mapStream = null;
try {
LOG.info("Loading Dozer mapping file {}.", configuration.getMappingFile());
// create the mapper instance and add the mapping file
mapStream = ResourceHelper.resolveMandatoryResourceAsInputStream(getCamelContext(), configuration.getMappingFile());
answer.addMapping(mapStream);
} finally {
IOHelper.close(mapStream);
}
return answer;
}
use of org.dozer.DozerBeanMapper 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);
}
});
}
use of org.dozer.DozerBeanMapper 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();
}
use of org.dozer.DozerBeanMapper in project mastering-java by Kingminghuang.
the class Mapping method main.
public static void main(String[] args) {
SorterDto sorterDto1 = SorterDto.builder().sort_field("name").field_type(FieldType.STRING).field_order(2).direction(Direction.DESCENDING).case_sensitive(true).build();
SorterDto sorterDto2 = SorterDto.builder().sort_field("id").field_type(FieldType.LONG).field_order(1).direction(Direction.ASCENDING).case_sensitive(false).build();
SorterCriteriaDto sorterCriteriaDto = new SorterCriteriaDto("sort by", AssetType.ISSUE, Arrays.asList(sorterDto1, sorterDto2));
FilterDto filterDto1 = FilterDto.builder().filter_field("name").value("Peek").operator(FilterOperator.CONTAINS).field_type(FieldType.STRING).field_order(1).is_and_condition(true).is_or_condition(false).has_open_parenthesis(true).has_close_parenthesis(false).build();
FilterDto filterDto2 = FilterDto.builder().filter_field("platform").value("Linux").operator(FilterOperator.EQUALS).field_type(FieldType.STRING).field_order(2).is_and_condition(false).is_or_condition(false).has_open_parenthesis(false).has_close_parenthesis(true).build();
FilterCriteriaDto filterCriteriaDto = new FilterCriteriaDto("filter", AssetType.REQUIREMENT, Arrays.asList(filterDto1, filterDto2));
DozerBeanMapper mapper = new DozerBeanMapper();
mapper.setMappingFiles(Arrays.asList("dozerBeanMapping.xml"));
SorterCriteria sorterCriteria = mapper.map(sorterCriteriaDto, SorterCriteria.class);
System.out.println(sorterCriteria);
FilterCriteria filterCriteria = mapper.map(filterCriteriaDto, FilterCriteria.class);
System.out.println(filterCriteria);
}
Aggregations