当前位置: 首页>>代码示例>>Java>>正文


Java TypeFactory类代码示例

本文整理汇总了Java中ma.glasnost.orika.metadata.TypeFactory的典型用法代码示例。如果您正苦于以下问题:Java TypeFactory类的具体用法?Java TypeFactory怎么用?Java TypeFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TypeFactory类属于ma.glasnost.orika.metadata包,在下文中一共展示了TypeFactory类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mapAsSet

import ma.glasnost.orika.metadata.TypeFactory; //导入依赖的package包/类
@Override
public <S, D> Set<D> mapAsSet(Iterable<S> source, Class<D> destinationClass) {
    Class<S> elclass = this.getElementClass(source);
    if(elclass==null){
        return new HashSet<D>(0);
    }
    addMappingIfNotRegistered(TypeFactory.valueOf(elclass),TypeFactory.valueOf(destinationClass));
    return this.mapper.mapAsSet(source,destinationClass);
}
 
开发者ID:yjy8749,项目名称:orika-mapper,代码行数:10,代码来源:Mapper.java

示例2: mapAsList

import ma.glasnost.orika.metadata.TypeFactory; //导入依赖的package包/类
@Override
public <S, D> List<D> mapAsList(Iterable<S> source, Class<D> destinationClass) {
    Class<S> elclass = this.getElementClass(source);
    if(elclass==null){
        return new ArrayList<D>(0);
    }
    addMappingIfNotRegistered(TypeFactory.valueOf(elclass),TypeFactory.valueOf(destinationClass));
    return this.mapper.mapAsList(source,destinationClass);
}
 
开发者ID:yjy8749,项目名称:orika-mapper,代码行数:10,代码来源:Mapper.java

示例3: mapAsArray

import ma.glasnost.orika.metadata.TypeFactory; //导入依赖的package包/类
@Override
public <S, D> D[] mapAsArray(D[] destination, Iterable<S> source, Class<D> destinationClass) {
    Class<S> elclass = this.getElementClass(source);
    if(elclass==null){
        return (D[]) new Object[1];
    }
    addMappingIfNotRegistered(TypeFactory.valueOf(elclass),TypeFactory.valueOf(destinationClass));
    return this.mapper.mapAsArray(destination,source,destinationClass);
}
 
开发者ID:yjy8749,项目名称:orika-mapper,代码行数:10,代码来源:Mapper.java

示例4: mapAsCollection

import ma.glasnost.orika.metadata.TypeFactory; //导入依赖的package包/类
@Override
public <S, D> void mapAsCollection(Iterable<S> source, Collection<D> destination, Class<D> destinationClass) {
    Class<S> elclass = this.getElementClass(source);
    if(elclass==null){
        return;
    }
    addMappingIfNotRegistered(TypeFactory.valueOf(elclass),TypeFactory.valueOf(destinationClass));
    this.mapper.mapAsCollection(source,destination,destinationClass);
}
 
开发者ID:yjy8749,项目名称:orika-mapper,代码行数:10,代码来源:Mapper.java

示例5: newObject

import ma.glasnost.orika.metadata.TypeFactory; //导入依赖的package包/类
@Override
public <S, D> D newObject(S source, Type<? extends D> destinationType, MappingContext context) {
    if(source==null){
        return null;
    }
    addMappingIfNotRegistered(TypeFactory.valueOf(source.getClass()),destinationType);
    return this.mapper.newObject(source,destinationType,context);
}
 
开发者ID:yjy8749,项目名称:orika-mapper,代码行数:9,代码来源:Mapper.java

示例6: ClonerConverter

import ma.glasnost.orika.metadata.TypeFactory; //导入依赖的package包/类
/**
 * Constructs a new ClonerConverter configured to handle the provided list of types by
 * cloning.
 * @param cloneStrategy Strategy to be used
 * @param types one or more types that should be copied using the ClonerConverter
 */
public ClonerConverter(CloneStrategy cloneStrategy, java.lang.reflect.Type... types) {

    this.cloner = new BasicCloner(cloneStrategy);

    if (types.length == 0) {
        this.types = null;
    }
    for (java.lang.reflect.Type type : types) {
        this.types.add(TypeFactory.valueOf(type));
    }
}
 
开发者ID:JadiraOrg,项目名称:jadira,代码行数:18,代码来源:ClonerConverter.java

示例7: copy

import ma.glasnost.orika.metadata.TypeFactory; //导入依赖的package包/类
/**
 * 指定复制的src和target的class.
 */
public <S, D> void copy(S src, D target, Class<S> srcClass,
        Class<D> targetClass) {
    mapper.map(src, target, TypeFactory.valueOf(srcClass),
            TypeFactory.valueOf(targetClass));
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:9,代码来源:BeanMapper.java

示例8: getType

import ma.glasnost.orika.metadata.TypeFactory; //导入依赖的package包/类
/**
 * 预先获取orika转换所需要的Type,避免每次转换.
 */
public static <E> Type<E> getType(final Class<E> rawType) {
	return TypeFactory.valueOf(rawType);
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:7,代码来源:BeanMapper.java

示例9: addMappingIfNotRegistered

import ma.glasnost.orika.metadata.TypeFactory; //导入依赖的package包/类
private void addMappingIfNotRegistered(Class<?> sourceClass, Class<?> destinationClass) {
    addMappingIfNotRegistered(TypeFactory.valueOf(sourceClass),TypeFactory.valueOf(destinationClass));
}
 
开发者ID:yjy8749,项目名称:orika-mapper,代码行数:4,代码来源:Mapper.java

示例10: convertObjectToMap

import ma.glasnost.orika.metadata.TypeFactory; //导入依赖的package包/类
/**
 * Convert an object to a Map
 *
 * @param object object to convert
 * @return Map&lt;String, Object&gt; converted object
 */
protected Map<String, Object> convertObjectToMap(Object object) {
  Type objectType = TypeFactory.valueOf(object.getClass());
  Type mapType = new TypeBuilder<Map<String, Object>>() {
  }.build();

  MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
  mapperFactory.classMap(objectType, mapType).byDefault().register();
  BoundMapperFacade boundMapper = mapperFactory.getMapperFacade(objectType, mapType);
  Map<String, Object> convertedObject = (Map<String, Object>) boundMapper.map(object);

  return convertedObject;
}
 
开发者ID:benjamin-cartereau,项目名称:w4-bpmnplus-module-jms,代码行数:19,代码来源:AbstractW4MessageListener.java

示例11: mapList

import ma.glasnost.orika.metadata.TypeFactory; //导入依赖的package包/类
/**
 * 简单的复制出新对象列表到ArrayList
 * 
 * 不建议使用mapper.mapAsList(Iterable<S>,Class<D>)接口, sourceClass需要反射,实在有点慢
 */
public static <S, D> List<D> mapList(Iterable<S> sourceList, Class<S> sourceClass, Class<D> destinationClass) {
	return mapper.mapAsList(sourceList, TypeFactory.valueOf(sourceClass), TypeFactory.valueOf(destinationClass));
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:9,代码来源:BeanMapper.java

示例12: doMapping

import ma.glasnost.orika.metadata.TypeFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <From, To> To doMapping(final Class<To> toClass, From from, String mappingName, MappingType mappingType, boolean beenMappedWithOrika, To to) {

    CustomMappingWrapper.Orika orikaOverrideSetting = CustomMappingWrapper.Orika.DEFAULT;

    if (from == null) return null;

    if (from instanceof CustomMappingWrapper) {
        CustomMappingWrapper cmo = (CustomMappingWrapper) from;
        from = (From)cmo.getObject();
        mappingType = cmo.getMappingType();
        mappingName = cmo.getMappingName();
        orikaOverrideSetting = cmo.getOrika();

        if (from == null) return null;

    }

    Class fromClass = from.getClass();

    boolean mappedWithOrika = false;

    if (orikaOverrideSetting == CustomMappingWrapper.Orika.FORCE_ON || (orikaOverrideSetting == CustomMappingWrapper.Orika.DEFAULT && (!beenMappedWithOrika && autoMapUsingOrika))) {

        //TODO move to cache
        MapperFacade orikaMapper;

        if (!mapperFactory.existsRegisteredMapper(TypeFactory.valueOf(from.getClass()), TypeFactory.valueOf(toClass), false)) {

            mapperFactory.classMap(fromClass, toClass)
                    .byDefault().register();
        }

        orikaMapper = mapperFactory.getMapperFacade();

        to = orikaMapper.map(from, toClass);

        beenMappedWithOrika = true;
        mappedWithOrika = true;

    }

    if (to == null) {
        try {
            to = toClass.newInstance();
        } catch (IllegalAccessException | InstantiationException e) {
            throw new RuntimeException("Error creating instace of " + toClass, e);
        }
    }

    doAudibleMapping(toClass, from, mappingName, mappingType, fromClass, to, beenMappedWithOrika, mappedWithOrika);

    handlePostProcessor(to, toClass, from, mappingName);

    return to;
}
 
开发者ID:nfl,项目名称:audible,代码行数:57,代码来源:DomainMapper.java


注:本文中的ma.glasnost.orika.metadata.TypeFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。