Java Code Examples for net.dreamlu.mica.core.utils.BeanUtil#newInstance()

The following examples show how to use net.dreamlu.mica.core.utils.BeanUtil#newInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BeanCopyUtilTest.java    From mica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static <T> T copyWithConvert(Object source, Class<T> targetClazz) {
	Class<?> sourceClass = source.getClass();
	MicaBeanCopier copier = MicaBeanCopier.create(source.getClass(), targetClazz, true, false);
	T to = BeanUtil.newInstance(targetClazz);
	copier.copy(source, to, new MicaConverter(sourceClass, targetClazz));
	return to;
}
 
Example 2
Source File: BeanCopyBenchmark.java    From mica-jmh with MIT License 5 votes vote down vote up
@Benchmark
public ToUser cglibBeanCopy() {
	ToUser toUser = BeanUtil.newInstance(ToUser.class);
	BeanCopier beanCopier = BeanCopier.create(FormUser.class, ToUser.class, false);
	beanCopier.copy(user, toUser, null);
	return toUser;
}
 
Example 3
Source File: MicaBeanCopier.java    From mica with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected Object firstInstance(Class type) {
	return BeanUtil.newInstance(type);
}
 
Example 4
Source File: BeanCopyUtilTest.java    From mica with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static <T> T copy(Object source, Class<T> targetClazz) {
	MicaBeanCopier copier = MicaBeanCopier.create(source.getClass(), targetClazz, false, false);
	T to = BeanUtil.newInstance(targetClazz);
	copier.copy(source, to, null);
	return to;
}
 
Example 5
Source File: BeanCopyBenchmark.java    From mica-jmh with MIT License 4 votes vote down vote up
@Benchmark
public ToUser cglibMapperBeanCopy() {
	ToUser toUser = BeanUtil.newInstance(ToUser.class);
	CglibMapper.MAPPER.copy(user, toUser, null);
	return toUser;
}