當前位置: 首頁>>代碼示例>>Java>>正文


Java DozerBeanMapper類代碼示例

本文整理匯總了Java中org.dozer.DozerBeanMapper的典型用法代碼示例。如果您正苦於以下問題:Java DozerBeanMapper類的具體用法?Java DozerBeanMapper怎麽用?Java DozerBeanMapper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DozerBeanMapper類屬於org.dozer包,在下文中一共展示了DozerBeanMapper類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ConverterUtil

import org.dozer.DozerBeanMapper; //導入依賴的package包/類
/**
 * 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(AuditDto.class, AuditInfo.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;
}
 
開發者ID:Netflix,項目名稱:metacat,代碼行數:31,代碼來源:ConverterUtil.java

示例2: map

import org.dozer.DozerBeanMapper; //導入依賴的package包/類
public static void map(final Object source, final Object destination, boolean ignoreNull) {
    DozerBeanMapper mapper = new DozerBeanMapper();
    if(ignoreNull) {
        mapper.addMapping(new BeanMappingBuilder() {
            protected void configure() {
                mapping(source.getClass(), destination.getClass(), mapNull(false), mapEmptyString(true));
            }
        });
    }

    mapper.map(source, destination);
}
 
開發者ID:Martion2017,項目名稱:ApplicationDetection,代碼行數:13,代碼來源:BeanMapperUtil.java

示例3: covertTweet

import org.dozer.DozerBeanMapper; //導入依賴的package包/類
private Tweet covertTweet(org.springframework.social.twitter.api.Tweet tweet) {

        Mapper mapper = new DozerBeanMapper();

        Tweet tweetNew = mapper.map(tweet, Tweet.class);
        tweetNew.setId(index++);

        Entities entities = mapper.map(tweet.getEntities(), Entities.class);
//        entities.setId(index++);
        tweetNew.setEntities(entities);

        TwitterProfile user = mapper.map(tweet.getUser(), TwitterProfile.class);
        user.setId(index++);
        tweetNew.setUser(user);

        return tweetNew;
    }
 
開發者ID:thinksky-sourcecode,項目名稱:microservices-prototype,代碼行數:18,代碼來源:DataService.java

示例4: DozerTypeConverterLoader

import org.dozer.DozerBeanMapper; //導入依賴的package包/類
/**
 * Creates a <code>DozerTypeConverter</code> using the given
 * {@link DozerBeanMapperConfiguration} configuration.
 *
 * @param camelContext the context to register the
 *                     {@link DozerTypeConverter} in
 *
 * @param configuration dozer mapping bean configuration.
 */
public DozerTypeConverterLoader(CamelContext camelContext, DozerBeanMapperConfiguration configuration) {
    ClassLoader tccl = Thread.currentThread().getContextClassLoader();
    try {
        ClassLoader appcl = camelContext.getApplicationContextClassLoader();
        if (appcl != null) {
            Thread.currentThread().setContextClassLoader(appcl);
        }
        log.info("Using DozerBeanMapperConfiguration: {}", configuration);
        DozerBeanMapper mapper = createDozerBeanMapper(configuration);

        this.camelContext = camelContext;
        this.mapper = mapper;
        this.configuration = configuration;

        camelContext.addService(this);
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    } finally {
        Thread.currentThread().setContextClassLoader(tccl);
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:31,代碼來源:DozerTypeConverterLoader.java

示例5: createDozerBeanMapper

import org.dozer.DozerBeanMapper; //導入依賴的package包/類
/**
 * Creates a {@link DozerBeanMapper} from the given configuration.
 *
 * @param configuration  the dozer bean mapper configuration.
 * @return the created mapper
 */
public static DozerBeanMapper createDozerBeanMapper(DozerBeanMapperConfiguration configuration) {
    DozerBeanMapper mapper;
    if (configuration.getMappingFiles() != null) {
        mapper = DozerComponent.createDozerBeanMapper(configuration.getMappingFiles());
    } else {
        mapper = DozerComponent.createDozerBeanMapper(Collections.<String>emptyList());
    }
    if (configuration.getCustomConverters() != null) {
        mapper.setCustomConverters(configuration.getCustomConverters());
    }
    if (configuration.getEventListeners() != null) {
        mapper.setEventListeners(configuration.getEventListeners());
    }
    if (configuration.getCustomConvertersWithId() != null) {
        mapper.setCustomConvertersWithId(configuration.getCustomConvertersWithId());
    }
    if (configuration.getCustomFieldMapper() != null) {
        mapper.setCustomFieldMapper(configuration.getCustomFieldMapper());
    }
    return mapper;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:28,代碼來源:DozerTypeConverterLoader.java

示例6: loadMappings

import org.dozer.DozerBeanMapper; //導入依賴的package包/類
private List<ClassMap> loadMappings(CamelContext camelContext, String mapperId, DozerBeanMapper mapper) {
    List<ClassMap> answer = new ArrayList<ClassMap>();

    // load the class map using the class resolver so we can load from classpath in OSGi
    MappingFileReader reader = new MappingFileReader(XMLParserFactory.getInstance());
    List<String> mappingFiles = mapper.getMappingFiles();
    if (mappingFiles == null) {
        return Collections.emptyList();
    }

    for (String name : mappingFiles) {
        URL url = loadMappingFile(camelContext.getClassResolver(), name);
        if (url != null) {
            MappingFileData data = reader.read(url);
            answer.addAll(data.getClassMaps());
        }
    }

    return answer;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:21,代碼來源:DozerTypeConverterLoader.java

示例7: setUp

import org.dozer.DozerBeanMapper; //導入依賴的package包/類
/**
 * Sets up the readers for the tests (all four constructor varieties are tested!).
 */
@Before
public void setUp() {
	reader = new StringReader(CSV);
	beanReader = new CsvDozerBeanReader(reader, PREFS);
	
	tokenizer = new Tokenizer(reader, PREFS);
	tokenizerBeanReader = new CsvDozerBeanReader(tokenizer, PREFS);
	
	beanMapper = new DozerBeanMapper();
	beanReaderWithMapper = new CsvDozerBeanReader(reader, PREFS, beanMapper);
	
	configuredBeanMapper = new DozerBeanMapper(Arrays.asList("reference.xml"));
	beanReaderWithConfiguredMapper = new CsvDozerBeanReader(reader, PREFS, configuredBeanMapper);
	
	tokenizerBeanReaderWithMapper = new CsvDozerBeanReader(tokenizer, PREFS, beanMapper);
}
 
開發者ID:super-csv,項目名稱:super-csv,代碼行數:20,代碼來源:CsvDozerBeanReaderTest.java

示例8: executeInternal

import org.dozer.DozerBeanMapper; //導入依賴的package包/類
@Override
protected SavePropertyResult executeInternal(SaveProperty action, ExecutionContext context) throws ActionException {
	DozerBeanMapper mapper = new DozerBeanMapper();

	Properties property = mapper.map(action.getProperties(), Properties.class);

	Contentholder originalProperty = contentholderDAOProvider.get().get(action.getProperties().getId());
	property.setContentitems(originalProperty.getContentitems());
	property.setTimeStamp(System.currentTimeMillis());
	System.out.println("The property  being saved = " + property.getId());
	Users user = getUser();
	System.out.println("The user  =" + user);
	property.setUser(user);
	BaseWIPSvcHelper helper = new BaseWIPSvcHelper((Contentholder) property, contentholderDAOProvider.get(),
			itemDAOProvider.get());
	property = (Properties) helper.checkin();
	postSaveOrUpdateproperties(property);
	System.out.println("The property  that got checkedin =" + property.getId());
	PropertiesDTO pDTO = DozerBeanMapperSingletonWrapper.getInstance().map(property, PropertiesDTO.class);
	return new SavePropertyResult(pDTO);
}
 
開發者ID:jchaganti,項目名稱:gharonda,代碼行數:22,代碼來源:SavePropertyHandler.java

示例9: instance

import org.dozer.DozerBeanMapper; //導入依賴的package包/類
/** Returns the Singleton instance.
 * @return the Singleton instance.
 */
public static DozerBeanMapper instance() {
    if (c_instance == null) {
        createInstance();
    }
    return c_instance;
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:10,代碼來源:DozerBeanMapperSingletonWrapper.java

示例10: sourceToDestinationMapping

import org.dozer.DozerBeanMapper; //導入依賴的package包/類
/**
 * @param source. The source object that needs to map to destination.
 * @param destination. The destination object that needs to map from source.
 * @return destination object
 */
public static Object sourceToDestinationMapping(Object source, Class destination) {

    DozerBeanMapper mapper = DozerBeanMapperSingletonWrapper.instance();
    Object destinationObj = mapper.map(source, destination);

    return destinationObj;
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:13,代碼來源:MappingHelper.java

示例11: mapper

import org.dozer.DozerBeanMapper; //導入依賴的package包/類
@Bean
public DozerBeanMapper mapper() {
    final DozerBeanMapper dozerBeanMapper = new DozerBeanMapper();
    dozerBeanMapper.setMappingFiles(Collections.singletonList("dozerJdk8Converters.xml"));
    dozerBeanMapper.addMapping(new StockToStockDtoMapping());
    return dozerBeanMapper;
}
 
開發者ID:akraskovski,項目名稱:product-management-system,代碼行數:8,代碼來源:DozerConfig.java

示例12: getDozer

import org.dozer.DozerBeanMapper; //導入依賴的package包/類
/**
 * @return the {@link DozerBeanMapper}.
 */
@Bean
public Mapper getDozer() {

  List<String> beanMappings = new ArrayList<>();
  beanMappings.add(DOZER_MAPPING_XML);
  return new DozerBeanMapper(beanMappings);

}
 
開發者ID:oasp,項目名稱:oasp-tutorial-sources,代碼行數:12,代碼來源:BeansDozerConfig.java

示例13: testDozer

import org.dozer.DozerBeanMapper; //導入依賴的package包/類
public Profiler testDozer(int invokeNum, String frameworkName) {
    DozerBeanMapper mapper = new DozerBeanMapper();
    long start = System.currentTimeMillis();
    for (int i = 0; i < invokeNum; i++) {
        Person7 p = getPerson();
        PersonDto dto = mapper.map(p, PersonDto.class);
        //System.out.println(dto);
    }
    return Profiler.apply(System.currentTimeMillis(), start)
            .setFrameworkName(frameworkName);
}
 
開發者ID:neoremind,項目名稱:easy-mapper,代碼行數:12,代碼來源:BenchmarkTest.java

示例14: useJEntityGraphDataMapper

import org.dozer.DozerBeanMapper; //導入依賴的package包/類
/**
 * Combines using an entityGraph for accessing data from a database with
 * dozer mapping and returns a decoupled data object
 * 
 * @param em
 *            entity manager for database access
 * @param classTypeBE
 *            source object type
 * @param classTypeDO
 *            destination object type
 * @param entityGraphName
 *            name of the entity graph
 * @param id
 *            identification number for accessed entity
 * @return data object of type classTypeDO
 */
public <BE, DO> DO useJEntityGraphDataMapper(final EntityManager em, final Class<BE> classTypeBE,
		final Class<DO> classTypeDO, final String entityGraphName, final int id) {
	final BuildDozerMapping dozerMappingBuilder = new BuildDozerMapping();
	final BuildEntityGraph entityGraphBuilder = new BuildEntityGraph();

	BE businessEntity = null;
	DO dataObject = null;
	try {
		dataObject = classTypeDO.newInstance();
	} catch (InstantiationException | IllegalAccessException e) {
		e.printStackTrace();
	}

	@SuppressWarnings("unchecked")
	final EntityGraph<BE> xmlGraph = (EntityGraph<BE>) entityGraphBuilder.generateEntityGraphXPath(em,
			entityGraphName, classTypeBE);

	final Map<String, Object> hints = new HashMap<String, Object>();
	hints.put("javax.persistence.loadgraph", xmlGraph);

	businessEntity = em.find(classTypeBE, id, hints);

	final DozerBeanMapper mapper = dozerMappingBuilder.generateMappingRulesXPath(entityGraphName);
	mapper.map(businessEntity, dataObject);

	return dataObject;
}
 
開發者ID:doubleSlashde,項目名稱:jEDM,代碼行數:44,代碼來源:JEntityGraphDataMapper.java

示例15: registerClassMaps

import org.dozer.DozerBeanMapper; //導入依賴的package包/類
protected void registerClassMaps(TypeConverterRegistry registry, String dozerId, DozerBeanMapper dozer, List<ClassMap> all) {
    DozerTypeConverter converter = new DozerTypeConverter(dozer);
    for (ClassMap map : all) {
        addDozerTypeConverter(registry, converter, dozerId, map.getSrcClassToMap(), map.getDestClassToMap());
        // if not one way then add the other way around also
        if (map.getType() != ONE_WAY) {
            addDozerTypeConverter(registry, converter, dozerId, map.getDestClassToMap(), map.getSrcClassToMap());
        }
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:11,代碼來源:DozerTypeConverterLoader.java


注:本文中的org.dozer.DozerBeanMapper類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。