复制一个对象并返回，属于浅度克隆，对象所属类必须符合JavaBean规范

@param bean 被复制的对象
@return 返回一个被复制对象的一个副本
519526
public static <T> T cloneBean(T bean) {
        try {
            T newBean = (T) BeanUtils.cloneBean(bean);
            return newBean;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
467872
public static boolean hasNull(Object bean) {
		final Field[] fields = ClassUtil.getDeclaredFields(bean.getClass());

		Object fieldValue = null;
		for (Field field : fields) {
			field.setAccessible(true);
			try {
				fieldValue = field.get(bean);
			} catch (Exception e) {
				//ignore
			}
			if (null == fieldValue) {
				return true;
			}
		}
		return false;
	}
692109
public Object getAssociatedBean(String beanId) {
        return registeredBeans == null ? null : registeredBeans.get(beanId);
    }
418173
protected Object getBeanPropertyValue(final String property, final Object bean) {
		if (bean == null) {
			return null;
		}

		if (".".equals(property)) {
			return bean;
		}

		try {
			Object data = PropertyUtils.getProperty(bean, property);
			return data;
		} catch (Exception e) {
			LOG.error("Failed to get bean property " + property + " on " + bean, e);
			return null;
		}
	}
1251957
public List<Bean> getBeans() {
        Map<BeanId, Bean> referenceMap = new HashMap<>();
        List<Bean> result = new ArrayList<>();

        for (HBeanRow row : inital.keySet()) {
            Bean bean = row.getBean();
            result.add(bean);
            referenceMap.put(bean.getId(), bean);
        }
        for (HBeanRow row : references.keySet()) {
            Bean bean = row.getBean();
            referenceMap.put(bean.getId(), bean);
        }
        for (Bean bean : referenceMap.values()) {
            for (BeanId id : bean.getReferences()) {
                Bean ref = referenceMap.get(id);
                id.setBean(ref);
            }
        }
        return result;
    }
1372656
public Object getBean(String name) {
		Bean bean = beans.get(name);
		if (null == bean) {
			return null;
		}
		return bean.object;
	}
1008146
public static Map<String, String> mapBean(final Object bean,
        final String exclude)
        {
        final Set<String> excludes = new HashSet<String>();
        if (!StringUtils.isBlank(exclude))
            {
            excludes.add(exclude);
            }
        return mapBean(bean, excludes);
        }
334835
public static void populateBean(final Object bean, 
        final Map<String, String> params) {
        final Method[] methods = bean.getClass().getMethods();
        for (final Method method : methods) {
            final Class<?>[] types = method.getParameterTypes();
            final int length = types.length;
            if (length != 1) {
                continue;
            }
            final String name = method.getName();
            if (!name.startsWith("set")) {
                continue;
            }
            final String fieldName = name.substring(3).toLowerCase();
            final String str = params.get(fieldName);
            if (str == null) {
                continue;
            }

            final String val = str.trim();
            
            final Class<?> type = types[0];
            
            final Object toAssign;
            if (type.isAssignableFrom(String.class)) {
                toAssign = val;
            }
            else if (type.isAssignableFrom(int.class)) {
                toAssign = Integer.parseInt(val);
            }
            else if (type.isAssignableFrom(boolean.class)) {
                toAssign = toBoolean(val);
            }
            else if (type.isAssignableFrom(Boolean.class)) {
                toAssign = toBoolean(val);
            }
            else if (type.isAssignableFrom(File.class)) {
                toAssign = new File(val);
            }
            else if (type.isAssignableFrom(URI.class)) {
                try {
                    toAssign = new URI(val);
                } catch (final URISyntaxException e) {
                    LOG.error("Error building bean", e);
                    throw new IllegalArgumentException("Error building bean",e);
                }
            }
            else if (type.isAssignableFrom(Integer.class)) {
                toAssign = Integer.parseInt(val);
            }
            else if (type.isAssignableFrom(int.class)) {
                toAssign = Integer.parseInt(val);
            }
            else if (type.isAssignableFrom(Float.class)) {
                toAssign = Float.parseFloat(val);
            }
            else if (type.isAssignableFrom(float.class)) {
                toAssign = Float.parseFloat(val);
            }
            else if (type.isAssignableFrom(Double.class)) {
                toAssign = Double.parseDouble(val);
            }
            else if (type.isAssignableFrom(double.class)) {
                toAssign = Double.parseDouble(val);
            }
            else if (type.isAssignableFrom(Long.class)) {
                toAssign = Long.parseLong(val);
            }
            else if (type.isAssignableFrom(long.class)) {
                toAssign = Long.parseLong(val);
            }
            else {
                final String msg = "Could not handle type: {}"+type.getName()+
                    " key: "+fieldName;
                LOG.error(msg);
                throw new IllegalArgumentException(msg);
            }
            try {
                method.invoke(bean, toAssign);
            } catch (final IllegalArgumentException e) {
                LOG.error("Could not invoke method", e);
            } catch (final IllegalAccessException e) {
                LOG.error("Could not invoke method", e);
            } catch (final InvocationTargetException e) {
                LOG.error("Could not invoke method", e);
            }
        }
    }
1155000
@SuppressWarnings("unchecked")
	public T getInstance() {
		if(beanClassName == null) {
			return null;
		} else try {
			T beanInstance;
			Class<T> beanClass = null;
			try {
				try {
					ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
					beanClass = (Class<T>)Class.forName(beanClassName, true, classLoader);
				} catch(ClassNotFoundException cnfe) {
					throw new RuntimeException("Unknown class " + beanClassName, cnfe);
				}
				// Instancjonowanie i inicjalizcja w oparciu o konstruktor inicjujący:
				Constructor<T> constructor = (Constructor<T>)beanClass.getConstructor(Collection.class);
				beanInstance = constructor.newInstance(properties);
			} catch(NoSuchMethodException nsme) {
				// Instancjonowanie i inicjalizacja w oparciu o konstruktor bezargumentowy
				// i publiczne setter'y Java Beans:
				beanInstance = beanClass.newInstance();

				if(properties != null && !properties.isEmpty()) {
					BeanInfo validatorInfo = Introspector.getBeanInfo(beanClass);
					PropertyDescriptor[] propertyDescriptors = validatorInfo.getPropertyDescriptors();
					for(BeanProperty beanProperty : properties) {
						String propertyName = beanProperty.getPropertyName();
						Method writeMethod = null;
						for(PropertyDescriptor propertyDescriptor : propertyDescriptors) {
							if(propertyDescriptor.getName().equals(propertyName)) {
								writeMethod = propertyDescriptor.getWriteMethod();
								break;
							}
						}
						if(writeMethod == null) {
							throw new RuntimeException("No public setter found for property '" + propertyName + "' "
									+ "in validator class " + beanClass.getCanonicalName());
						}
						Class<?> parameterType = writeMethod.getParameterTypes()[0];
						if(BeanProperty.class.equals(parameterType)) {
							writeMethod.invoke(beanInstance, beanProperty);
						} else if(String.class.equals(parameterType)) {
							if(beanProperty.hasAttributes()) {
								throw new RuntimeException("BeanProperty '" + propertyName + "' setter should has "
										+ Parameter.class.getSimpleName() + " type parameter");
							}
							writeMethod.invoke(beanInstance, beanProperty.getPropertyValue());
						}
					}
				}
			}
			return beanInstance;
		} catch(Exception e) {
			throw new RuntimeException(e);
		}
	}
752673
public <T> T toBeanIgnoreCase(T bean) {
		BeanUtil.fillBeanWithMapIgnoreCase(this, bean, false);
		return bean;
	}
1038140
public JSONObject processBean( Object bean, JsonConfig jsonConfig ) {
      JSONObject jsonObject = null;
      if( bean instanceof java.sql.Date ){
         bean = new Date( ((java.sql.Date) bean).getTime() );
      }
      if( bean instanceof Date ){
         Calendar c = Calendar.getInstance();
         c.setTime( (Date) bean );
         jsonObject = new JSONObject().element( "year", c.get( Calendar.YEAR ) )
               .element( "month", c.get( Calendar.MONTH ) )
               .element( "day", c.get( Calendar.DAY_OF_MONTH ) )
               .element( "hours", c.get( Calendar.HOUR_OF_DAY ) )
               .element( "minutes", c.get( Calendar.MINUTE ) )
               .element( "seconds", c.get( Calendar.SECOND ) )
               .element( "milliseconds", c.get( Calendar.MILLISECOND ) );
      }else{
         jsonObject = new JSONObject( true );
      }
      return jsonObject;
   }
138623
public <T> Dict parseBean(T bean, boolean isToUnderlineCase, boolean ignoreNullValue) {
		Assert.notNull(bean, "Bean class must be not null");
		this.putAll(BeanUtil.beanToMap(bean, isToUnderlineCase, ignoreNullValue));
		return this;
	}
635338
protected List getBeansToUpdate(Class beanType) {
        final ApplicationContext ac = getApplicationContext();
        final List listeners = new ArrayList();

        if( ac != null ) {
            if( logger.isDebugEnabled() )
                logger.debug( "Constructing list of beans to notify; bean type=" + beanType.getName() );

            final Map map = ac.getBeansOfType( beanType, false, true );

            if( logger.isDebugEnabled() )
                logger.debug( "bean map: " + map );

            listeners.addAll( map.values() );
            listeners.addAll( getNonSingletonListeners( beanType ) );
        }

        if( logger.isDebugEnabled() )
            logger.debug( "List of beans to notify:" + listeners );

        return listeners;
    }
1056834
protected Class<?> getBeanClass(String beanName) {
        Class<?> clazz = context.getType(beanName);
        while (Proxy.isProxyClass(clazz) || Enhancer.isEnhanced(clazz)) {
            clazz = clazz.getSuperclass();
        }
        return clazz;
    }
259251
public static boolean isPassivationCapableBean(Bean<?> bean) {
        if (bean instanceof RIBean<?>) {
            return ((RIBean<?>) bean).isPassivationCapableBean();
        } else {
            return bean instanceof PassivationCapable;
        }
    }
214952
private static void doBeanMapping(BeanMappingParam param, BeanMappingField beanField, BatchObjectHolder holder) {
        // 定义valueContext
        ValueProcessContext valueContext = new ValueProcessContext(param, param.getConfig(), beanField, holder,
                                                                   param.getCustomValueContext());
        // 检查一下targetClass是否有设置，针对bean对象有效
        // 如果目标对象是map，需要客户端强制设定targetClass
        GetExecutor getExecutor = beanField.getGetExecutor();
        if (getExecutor == null && StringUtils.isNotEmpty(beanField.getSrcField().getName())) {// 可能存在为空
            Class locatorClass = beanField.getSrcField().getLocatorClass();// 从locatorClass中获取
            if (locatorClass == null) {
                locatorClass = param.getSrcRef().getClass();
                beanField.getSrcField().setLocatorClass(locatorClass);
            }
            getExecutor = Uberspector.getInstance().getGetExecutor(locatorClass, beanField.getSrcField().getName());
            beanField.setGetExecutor(getExecutor);
        }

        SetExecutor setExecutor = beanField.getSetExecutor();
        if (setExecutor == null && StringUtils.isNotEmpty(beanField.getTargetField().getName())) {// 可能存在为空
            Class locatorClass = beanField.getTargetField().getLocatorClass();// 从locatorClass中获取
            if (locatorClass == null) {
                locatorClass = param.getTargetRef().getClass();
                beanField.getTargetField().setLocatorClass(locatorClass);
            }
            setExecutor = Uberspector.getInstance().getSetExecutor(locatorClass, beanField.getTargetField().getName(),
                                                                   beanField.getTargetField().getClazz());
            beanField.setSetExecutor(setExecutor);
        }

        // 获取新的srcRef
        // 获取get结果
        ValueProcessInvocation invocation = new ValueProcessInvocation(getExecutor, setExecutor, valueContext,
                                                                       param.getProcesses());
        Object srcRef = invocation.getInitialValue();

        // 设置下srcClass
        Class getResultClass = (srcRef != null) ? srcRef.getClass() : null;
        // 设置下srcClass
        if (getExecutor != null && beanField.getSrcField().getClazz() == null) {
            beanField.getSrcField().setClazz(
                                             Uberspector.getInstance().getGetClass(getExecutor,
                                                                                   param.getSrcRef().getClass(),
                                                                                   getResultClass));
        }

        if (setExecutor != null && beanField.getTargetField().getClazz() == null) {
            beanField.getTargetField().setClazz(
                                                Uberspector.getInstance().getSetClass(setExecutor,
                                                                                      param.getTargetRef().getClass(),
                                                                                      getResultClass));
            if (setExecutor instanceof MapSetExecutor) {
                beanField.getTargetField().setClazz(HashMap.class);// 注意这里强制传递为HashMap.class
            }
        }

        // 执行set,反射构造一个子Model
        // 如果嵌套对象为null，则直接略过该对象处理，目标对象也为null,此时srcRef可能为null
        Object value = invocation.proceed(srcRef); // 在目标节点对象上，创建一个子节点
        if (srcRef == null && value == null) {
            return; // 如果为null，则不做递归处理
        }

        if (beanField.getSrcField().getClazz() == null || beanField.getTargetField().getClazz() == null) {
            throw new BeanMappingException("srcClass or targetClass is null , " + beanField.toString());
        }
        // change for v1.0.2
        BeanMappingObject object = beanField.getNestObject();
        if (object == null) {
            if (StringUtils.isNotEmpty(beanField.getNestName())) {

                object = BeanMappingConfigHelper.getInstance().getBeanMappingObject(beanField.getNestName());
            } else {
                object = BeanMappingConfigHelper.getInstance().getBeanMappingObject(
                                                                                    beanField.getSrcField().getClazz(),
                                                                                    beanField.getTargetField().getClazz());
            }

            beanField.setNestObject(object);// cache一下结果
        }

        if (object == null) {
            throw new BeanMappingException("no bean mapping config for " + beanField.toString());
        }
        BeanMappingParam newParam = new BeanMappingParam();
        newParam.setTargetRef(value);// 为新创建的子model，注意使用value，可以在SetValueProcess中会创建新对象
        newParam.setSrcRef(srcRef);
        newParam.setConfig(object);
        // 复制并传递
        newParam.setProcesses(param.getProcesses());
        // 进行递归调用
        execute(newParam);
    }
97883
@Override
    @SuppressWarnings("unchecked")
    public P get(Bean bean) {
        return (P) getter.get(bean);
    }