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


Java BeanCopier类代码示例

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


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

示例1: copyProperties

import net.sf.cglib.beans.BeanCopier; //导入依赖的package包/类
public static void copyProperties(Object from, Object to) {
    BeanCopier bc = getCopier(from.getClass(), to.getClass());
    bc.copy(from, to, new Converter() {

        @Override
        public Object convert(Object value, @SuppressWarnings("rawtypes") Class target, Object context) {
            if (null != value && target.getName().equals("java.lang.String")) {
                return value.toString();
            } else if (null != value && target.isAssignableFrom(value.getClass())) {
                return value;
            }
            return null;
        }

    });
}
 
开发者ID:fintx,项目名称:fintx-common,代码行数:17,代码来源:Objects.java

示例2: ZkWatcher

import net.sf.cglib.beans.BeanCopier; //导入依赖的package包/类
public ZkWatcher(String hosts, int timeout, String path, T wob) throws IOException, KeeperException, InterruptedException, Exception {
    this.hosts = hosts;
    this.timeout = timeout;
    this.path = path;
    this.wob = wob;
    copier = BeanCopier.create(wob.getClass(), wob.getClass(), false);
    zkclient = CuratorFrameworkFactory.builder()
                .connectString(hosts)
                .sessionTimeoutMs(5000)
                .retryPolicy(retryPolicy)
                // .namespace(path)
                .build();
    zkclient.start();
    treeCache = new TreeCache(zkclient, path);
    treeCache.getListenable().addListener(this);
    treeCache.start();
    log.debug("treeCache=" + treeCache);
    init();
}
 
开发者ID:dpcn,项目名称:conf-from-zk,代码行数:20,代码来源:ZkWatcher.java

示例3: beanCopy

import net.sf.cglib.beans.BeanCopier; //导入依赖的package包/类
private static final <T> T beanCopy(Object source, T target, Converter converter) {
	if (source == null || target == null)
		return target;
	// always true
	boolean useConvert = converter != null;
	String beanKey = _generateKey(source.getClass(), target.getClass(), useConvert);
	BeanCopier copier = null;
	if (!beanCopiers.containsKey(beanKey)) {
		copier = BeanCopier.create(source.getClass(), target.getClass(), useConvert);
		beanCopiers.put(beanKey, copier);
	} else {
		copier = beanCopiers.get(beanKey);
	}
	copier.copy(source, target, converter);
	return target;
}
 
开发者ID:liyang-bsy,项目名称:LYLab,代码行数:17,代码来源:Caster.java

示例4: getCopier

import net.sf.cglib.beans.BeanCopier; //导入依赖的package包/类
private static BeanCopier getCopier(Class<?> clz1, Class<?> clz2) {
    if (beanCopiers.containsKey(clz1.getName() + clz2.getName()))
        return beanCopiers.get(clz1.getName() + clz2.getName());
    beanCopiers.putIfAbsent(clz1.getName() + clz2.getName(), BeanCopier.create(clz1, clz2, true));
    return beanCopiers.get(clz1.getName() + clz2.getName());

}
 
开发者ID:fintx,项目名称:fintx-common,代码行数:8,代码来源:Objects.java

示例5: copyProperties

import net.sf.cglib.beans.BeanCopier; //导入依赖的package包/类
/**
 * Copy the property values of the given source bean into the target bean.
 *
 * @param source the source bean
 * @param target the target bean
 *
 * @see BeanCopier
 */
@Override
public void copyProperties(Object source, Object target) {
    Objects.requireNonNull(source, "source must not be null");
    Objects.requireNonNull(target, "target must not be null");

    BeanCopier beanCopier = getBeanCopier(source.getClass(), target.getClass());
    beanCopier.copy(source, target, converter);
}
 
开发者ID:MottoX,项目名称:BeanUtils,代码行数:17,代码来源:BeanConverterImpl.java

示例6: copy

import net.sf.cglib.beans.BeanCopier; //导入依赖的package包/类
public static <S,T> void copy(S source, T target){
	Objects.requireNonNull(source);
	Objects.requireNonNull(target);
	
	String key = buildBeanCopierKey(source.getClass() ,target.getClass());
	BeanCopier beanCopier =  beanCopierMap.get(key);
	if(beanCopier == null){
		beanCopier = BeanCopier.create(source.getClass() ,target.getClass(), false);//not use Converter
		beanCopierMap.put(key, beanCopier);
	}
	
	beanCopier.copy(source, target, null);
}
 
开发者ID:haoran10,项目名称:springbase,代码行数:14,代码来源:BeanUtil.java

示例7: getCopier

import net.sf.cglib.beans.BeanCopier; //导入依赖的package包/类
private BeanCopier getCopier(Class<?> src, Class<?> dest) {
	Map<Class<?>, BeanCopier> dest2copier = src2dest2copier.get(src);
	if (dest2copier == null) {
		dest2copier = new HashMap<>();
		src2dest2copier.put(src, dest2copier);
	}

	BeanCopier copier = dest2copier.get(dest);
	if (copier == null) {
		copier = BeanCopier.create(src, dest, false);
		dest2copier.put(dest, copier);
	}
	return copier;
}
 
开发者ID:wooui,项目名称:springboot-training,代码行数:15,代码来源:BeanUtil.java

示例8: copyProperties

import net.sf.cglib.beans.BeanCopier; //导入依赖的package包/类
public static void copyProperties(Object source, Object target) {
	String beanKey = generateKey(source.getClass(), target.getClass());
	BeanCopier copier = null;
	copier = BeanCopier.create(source.getClass(), target.getClass(), false);
	beanCopierMap.putIfAbsent(beanKey, copier);
	copier = beanCopierMap.get(beanKey);
	copier.copy(source, target, null);
}
 
开发者ID:xbynet,项目名称:crawler,代码行数:9,代码来源:BeanUtil.java

示例9: testGetSet

import net.sf.cglib.beans.BeanCopier; //导入依赖的package包/类
public Profiler testGetSet(int invokeNum, String frameworkName) {
    BeanCopier b = BeanCopier.create(Person7.class, PersonDto.class, false);
    long start = System.currentTimeMillis();
    for (int i = 0; i < invokeNum; i++) {
        Person7 p = getPerson();
        PersonDto dto = new PersonDto();
        dto.setFirstName(p.getFirstName());
        dto.setLastName(p.getLastName());
        dto.setJobTitles(p.getJobTitles());
        dto.setSalary(p.getSalary());
        //System.out.println(dto);
    }
    return Profiler.apply(System.currentTimeMillis(), start)
            .setFrameworkName(frameworkName);
}
 
开发者ID:neoremind,项目名称:easy-mapper,代码行数:16,代码来源:BenchmarkTest.java

示例10: testBeanCopier

import net.sf.cglib.beans.BeanCopier; //导入依赖的package包/类
public Profiler testBeanCopier(int invokeNum, String frameworkName) {
    BeanCopier b = BeanCopier.create(Person7.class, PersonDto.class, false);
    long start = System.currentTimeMillis();
    for (int i = 0; i < invokeNum; i++) {
        Person7 p = getPerson();
        PersonDto dto = new PersonDto();
        b.copy(p, dto, null);
        //System.out.println(dto);
    }
    return Profiler.apply(System.currentTimeMillis(), start)
            .setFrameworkName(frameworkName);
}
 
开发者ID:neoremind,项目名称:easy-mapper,代码行数:13,代码来源:BenchmarkTest.java

示例11: copyProperties

import net.sf.cglib.beans.BeanCopier; //导入依赖的package包/类
public static void copyProperties(Object source, Object target) {
    String beanKey = generateKey(source.getClass(), target.getClass());
    BeanCopier copier = null;
    if (!beanCopierMap.containsKey(beanKey)) {
        copier = BeanCopier.create(source.getClass(), target.getClass(), false);
        beanCopierMap.put(beanKey, copier);
    } else {
        copier = beanCopierMap.get(beanKey);
    }
    copier.copy(source, target, null);
}
 
开发者ID:krisjin,项目名称:bscl,代码行数:12,代码来源:BeanCopierUtils.java

示例12: beanCopy

import net.sf.cglib.beans.BeanCopier; //导入依赖的package包/类
/**
 * 高性能的Bean copy
 * @param fromBean
 * @param toBean
 * @author huangxin
 */
public static void beanCopy(Object fromBean ,Object toBean){
	if (fromBean == null || toBean==null) {
		return;
	}
	BeanCopier b = BeanCopier.create(fromBean.getClass(), toBean.getClass(), false);
	b.copy(fromBean, toBean, null);
}
 
开发者ID:youngor,项目名称:openclouddb,代码行数:14,代码来源:JavaBeanUtil.java

示例13: copy

import net.sf.cglib.beans.BeanCopier; //导入依赖的package包/类
/**
 * 将from实体bean的属性值拷贝至to实体类的同名属性值, 可使用自定义转换器,
 * 如果使用了转换器,则由转换器完成所有的属性拷贝
 * 
 * @param from 源对象
 * @param to 目标对象
 * @param converter
 */
public static void copy(Object from, Object to, Converter converter) {
	if (from == null || to == null) {
		return;
	}
	boolean useConverter = (converter != null ? true : false);
	BeanCopier copier = BeanCopier.create(from.getClass(), to.getClass(),
			useConverter);
	copier.copy(from, to, converter);
}
 
开发者ID:leopardoooo,项目名称:easyooo-framework,代码行数:18,代码来源:CglibUtil.java

示例14: getBeanCopier

import net.sf.cglib.beans.BeanCopier; //导入依赖的package包/类
private static BeanCopier getBeanCopier(Class<?> sourceClass, Class<?> targetClass) {
    ClassPair classPair = new ClassPair(sourceClass, targetClass);
    BeanCopier beanCopier = beanCopiers.get(classPair);
    if (beanCopier == null) {
        BeanCopier copier = BeanCopier.create(sourceClass, targetClass, false);
        logger.info("Created BeanCopier(" + sourceClass + ',' + targetClass + ").");
        beanCopiers.putIfAbsent(classPair, copier);
        return beanCopiers.get(classPair);
    } else {
        return beanCopier;
    }
}
 
开发者ID:Codeforces,项目名称:inmemo,代码行数:13,代码来源:Inmemo.java

示例15: main

import net.sf.cglib.beans.BeanCopier; //导入依赖的package包/类
public static void main(String[] args) throws IllegalAccessException, InstantiationException {
    BeanCopier beanCopier = getBeanCopier(Person.class, Person.class);
    Person from = null; // new Person(); // new Person(123, 124, 125, Person.A.Y);
    Person to = Person.class.newInstance();
    beanCopier.copy(from, to, null);
    System.out.println(to);
}
 
开发者ID:Codeforces,项目名称:inmemo,代码行数:8,代码来源:Inmemo.java


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