All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.xbynet.crawler.utils.BeanUtil Maven / Gradle / Ivy

The newest version!
package com.github.xbynet.crawler.utils;

import java.util.concurrent.ConcurrentHashMap;

import net.sf.cglib.beans.BeanCopier;

public class BeanUtil {
	public static ConcurrentHashMap beanCopierMap = new ConcurrentHashMap();

	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);
	}

	private static String generateKey(Class class1, Class class2) {
		return class1.toString() + class2.toString();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy