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


Java BeanCopier.copy方法代码示例

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


在下文中一共展示了BeanCopier.copy方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: testDeepClone

import net.sf.cglib.beans.BeanCopier; //导入方法依赖的package包/类
@Test
public void testDeepClone() throws Exception {
    Constructor con = Objects.class.getDeclaredConstructor();  
    
    // 通过私有带参构造方法对象创建对象  
    // IllegalAccessException:非法的访问异常  
    // 暴力访问  
    con.setAccessible(true);// 值为true则指示反射的对象在使用时应该取消Java语言访问检查。  
    Object obj = con.newInstance();  
    BeanCopier bc=BeanCopier.create(String.class, String.class, false);
    String str=null;
    bc.copy("", str, null);
    Assert.assertTrue(String.class.equals("a".getClass()));
    Assert.assertTrue(Objects.isBaseType("a".getClass()));
    Assert.assertTrue(Objects.isBaseType(String.class));
    Assert.assertFalse(Objects.isBaseType(Date.class));
    Assert.assertFalse(Objects.isWrapperType("a".getClass()));
    Assert.assertTrue(Objects.isWrapperType(new Boolean(false).getClass()));
    // String a="a";
    // String b="a";
    // String c=new String("a");
    // Assert.assertTrue(a==b);
    // Assert.assertFalse(a==c);
    byte b = 1;
    b = Objects.deepClone(b);
    byte[] bytes = Objects.deepClone(new byte[10]);
    Array.getLength(bytes);
    Assert.assertTrue(10 == bytes.length);
    int[] ints = Objects.deepClone(new int[10]);
    Assert.assertTrue(10 == ints.length);
    PoJo pojo = new PoJo();
    pojo.setIn(0);
    ints[0] = 1;
    pojo.setIns(ints);
    pojo.setObjs(new Object[10]);
    pojo.setStr("aa");

    pojo.setStrs(new String[3]);
    bytes[9] = 10;
    pojo.setBytes(bytes);
    pojo.getBytes()[2] = 1;
    Assert.assertFalse(pojo == Objects.deepClone(pojo));
    Assert.assertTrue(0 == pojo.getIn());
    Assert.assertTrue(1 == pojo.getIns()[0]);
    Assert.assertTrue("aa".equals(pojo.getStr()));
    Assert.assertTrue(10 == pojo.getBytes()[9]);
    Assert.assertTrue(Objects.deepClone("a").equals("a"));
    String[] strs=Objects.deepClone(new String[] {"a","b"});
    Assert.assertTrue(strs[0].equals("a"));
}
 
开发者ID:fintx,项目名称:fintx-common,代码行数:51,代码来源:ObjectsTest.java

示例12: 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
 */
public static 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, null);
}
 
开发者ID:MottoX,项目名称:BeanUtils,代码行数:16,代码来源:BeanUtils.java


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