org.dozer.loader.api.BeanMappingBuilder Java Examples

The following examples show how to use org.dozer.loader.api.BeanMappingBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConverterUtil.java    From metacat with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param dozerTypeConverter custom dozer converter for types
 */
public ConverterUtil(@Nonnull @NonNull final DozerTypeConverter dozerTypeConverter) {
    final DozerBeanMapper dozerBeanMapper = new DozerBeanMapper();
    final BeanMappingBuilder builder = new BeanMappingBuilder() {
        @Override
        protected void configure() {
            mapping(FieldDto.class, FieldInfo.class)
                .fields("type", "type", FieldsMappingOptions.customConverterId("typeConverter"))
                .fields("partition_key", "partitionKey", FieldsMappingOptions.copyByReference())
                .fields("source_type", "sourceType", FieldsMappingOptions.copyByReference());
            mapping(TableDto.class, TableInfo.class)
                .fields("name", "name", FieldsMappingOptions.copyByReference());
            mapping(DatabaseDto.class, DatabaseInfo.class)
                .fields("name", "name", FieldsMappingOptions.copyByReference());
            mapping(PartitionDto.class, PartitionInfo.class)
                .fields("name", "name", FieldsMappingOptions.copyByReference());
            mapping(CatalogDto.class, CatalogInfo.class);
            mapping(ClusterDto.class, ClusterInfo.class);
            mapping(AuditDto.class, AuditInfo.class);
            mapping(ViewDto.class, ViewInfo.class);
            mapping(StorageDto.class, StorageInfo.class);
        }
    };
    dozerBeanMapper.addMapping(builder);
    final Map<String, CustomConverter> customConverterMap = Maps.newHashMap();
    customConverterMap.put("typeConverter", dozerTypeConverter);
    dozerBeanMapper.setCustomConvertersWithId(customConverterMap);
    this.mapper = dozerBeanMapper;
}
 
Example #2
Source File: DozerConfiguration.java    From WTFDYUM with Apache License 2.0 5 votes vote down vote up
private BeanMappingBuilder beanMappingBuilder() {
    return new BeanMappingBuilder() {
        @Override
        protected void configure() {
            // add mappings here
        }
    };
}