public static <P> P copyData(P source, P target) throws Exception { synchronized (beanUtils) { beanUtils.copyProperties(source, target); } return target; }
BeanUtilsBean notNull=new NullAwareBeanUtilsBean(); notNull.copyProperties(dest, orig);
/** * <p>Copy property values from the origin bean to the destination bean * for all cases where the property names are the same.</p> * * <p>For more details see <code>BeanUtilsBean</code>.</p> * * @param dest Destination bean whose properties are modified * @param orig Origin bean whose properties are retrieved * * @throws IllegalAccessException if the caller does not have * access to the property accessor method * @throws IllegalArgumentException if the <code>dest</code> or * <code>orig</code> argument is null or if the <code>dest</code> * property type is different from the source type and the relevant * converter has not been registered. * @throws InvocationTargetException if the property accessor method * throws an exception * @see BeanUtilsBean#copyProperties */ public static void copyProperties(final Object dest, final Object orig) throws IllegalAccessException, InvocationTargetException { BeanUtilsBean.getInstance().copyProperties(dest, orig); }
/** * <p>Copy property values from the origin bean to the destination bean * for all cases where the property names are the same.</p> * * <p>For more details see <code>BeanUtilsBean</code>.</p> * * @param dest Destination bean whose properties are modified * @param orig Origin bean whose properties are retrieved * * @throws IllegalAccessException if the caller does not have * access to the property accessor method * @throws IllegalArgumentException if the <code>dest</code> or * <code>orig</code> argument is null or if the <code>dest</code> * property type is different from the source type and the relevant * converter has not been registered. * @throws InvocationTargetException if the property accessor method * throws an exception * @see BeanUtilsBean#copyProperties */ public static void copyProperties(final Object dest, final Object orig) throws IllegalAccessException, InvocationTargetException { BeanUtilsBean.getInstance().copyProperties(dest, orig); }
public static <P> P copyData(P source, P target) throws Exception { synchronized (beanUtils) { beanUtils.copyProperties(source, target); } return target; }
public static <P> P copyData(P source, P target) throws Exception { synchronized (beanUtils) { beanUtils.copyProperties(source, target); } return target; }
public static <P> P copyData(P source, P target) throws Exception { synchronized (beanUtils) { beanUtils.copyProperties(source, target); } return target; }
public static synchronized void copyPropesrties(Map source, Object dest) throws IllegalAccessException, InvocationTargetException { bean.copyProperties(dest, source); }
private static void copyProperties(Object from,Object to,BeanUtilsBean bub){ try { bub.copyProperties(to,from); } catch (Exception e) { throw new RuntimeException(e); } } }
/** * 属性拷贝 * @param dest * @param orig */ public static void copyProperties(Object dest, Object orig){ try { BeanUtilsBean.getInstance().copyProperties(dest,orig); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } }
/** * <p>Copy property values from the origin bean to the destination bean * for all cases where the property names are the same.</p> * * <p>For more details see <code>BeanUtilsBean</code>.</p> * * @param dest Destination bean whose properties are modified * @param orig Origin bean whose properties are retrieved * * @exception IllegalAccessException if the caller does not have * access to the property accessor method * @exception IllegalArgumentException if the <code>dest</code> or * <code>orig</code> argument is null or if the <code>dest</code> * property type is different from the source type and the relevant * converter has not been registered. * @exception InvocationTargetException if the property accessor method * throws an exception * @see BeanUtilsBean#copyProperties */ public static void copyProperties(Object dest, Object orig) throws IllegalAccessException, InvocationTargetException { BeanUtilsBean.getInstance().copyProperties(dest, orig); }
/** * <p>Copy property values from the origin bean to the destination bean * for all cases where the property names are the same.</p> * * <p>For more details see <code>BeanUtilsBean</code>.</p> * * @param dest Destination bean whose properties are modified * @param orig Origin bean whose properties are retrieved * * @throws IllegalAccessException if the caller does not have * access to the property accessor method * @throws IllegalArgumentException if the <code>dest</code> or * <code>orig</code> argument is null or if the <code>dest</code> * property type is different from the source type and the relevant * converter has not been registered. * @throws InvocationTargetException if the property accessor method * throws an exception * @see BeanUtilsBean#copyProperties */ public static void copyProperties(final Object dest, final Object orig) throws IllegalAccessException, InvocationTargetException { BeanUtilsBean.getInstance().copyProperties(dest, orig); }
/** * <p>Copy property values from the origin bean to the destination bean * for all cases where the property names are the same.</p> * * <p>For more details see <code>BeanUtilsBean</code>.</p> * * @param dest Destination bean whose properties are modified * @param orig Origin bean whose properties are retrieved * * @exception IllegalAccessException if the caller does not have * access to the property accessor method * @exception IllegalArgumentException if the <code>dest</code> or * <code>orig</code> argument is null or if the <code>dest</code> * property type is different from the source type and the relevant * converter has not been registered. * @exception InvocationTargetException if the property accessor method * throws an exception * @see BeanUtilsBean#copyProperties */ public static void copyProperties(Object dest, Object orig) throws IllegalAccessException, InvocationTargetException { BeanUtilsBean.getInstance().copyProperties(dest, orig); }
/** * <p>Copy property values from the origin bean to the destination bean * for all cases where the property names are the same.</p> * * <p>For more details see <code>BeanUtilsBean</code>.</p> * * @param dest Destination bean whose properties are modified * @param orig Origin bean whose properties are retrieved * * @exception IllegalAccessException if the caller does not have * access to the property accessor method * @exception IllegalArgumentException if the <code>dest</code> or * <code>orig</code> argument is null or if the <code>dest</code> * property type is different from the source type and the relevant * converter has not been registered. * @exception InvocationTargetException if the property accessor method * throws an exception * @see BeanUtilsBean#copyProperties */ public static void copyProperties(Object dest, Object orig) throws IllegalAccessException, InvocationTargetException { BeanUtilsBean.getInstance().copyProperties(dest, orig); }
public static void copyProperties(Object arg0, Object arg1) throws IllegalAccessException, InvocationTargetException { java.util.Date defaultValue = null; Converter converter = new DateConverter(defaultValue); BeanUtilsBean beanUtilsBean = BeanUtilsBean.getInstance(); beanUtilsBean.getConvertUtils().register(converter, java.util.Date.class); beanUtilsBean.copyProperties(arg0, arg1); }
/** * 拷贝属性 * * @param sources 源 * @param targetClass 目标 class * @param <T> 目标类型 * @return 目标集合 */ public static < T > List< T > copyPropertiesToList ( List< ? > sources , Class<T> targetClass) { AssertUtils.isTrue( CollectionUtils.isEmpty( sources ), "sources is null" ); AssertUtils.isTrue( targetClass == null, "targetClass is null" ); List< T > targets = new ArrayList<>( sources.size() ); for ( Object source : sources ) { T target; try { target = targetClass.newInstance(); BeanUtilsBean2.getInstance().copyProperties( target , source ); } catch ( InstantiationException | IllegalAccessException | InvocationTargetException e ) { throw new RuntimeException( e.getMessage() , e ); } targets.add( target ); } return targets; }
public class BeanUtilCopy { private static BeanUtilsBean beanUtilsBean; private static ConvertUtilsBean convertUtilsBean = new ConvertUtilsBean(); static { convertUtilsBean.register(new Converter() { //2 public <T> T convert(Class<T> type, Object value) { T dest = null; try { dest = type.newInstance(); BeanUtils.copyProperties(dest, value); } catch (Exception e) { e.printStackTrace(); } return dest; } }, Wheel.class); beanUtilsBean = new BeanUtilsBean(convertUtilsBean); } public static void copyBean(Object dest, Object orig) throws Exception { beanUtilsBean.copyProperties(dest, orig); //1 }
public Object convert(Class type, Object value) { try { LazyDynaMap dynaMap = new LazyDynaMap((Map<String, Object>) value); WrapDynaBean bean = (WrapDynaBean) WrapDynaClass.createDynaClass(type).newInstance(); beanUtils.copyProperties(bean, dynaMap); beanUtils.copyProperty(bean, "", value); return bean.getInstance(); } catch (Exception e) { throw new UnhandledException(e); } } }