将一个Map对象转换成一个Bean对象

@param property 一个Map对象，封装了相应的Bean中的属性
@param clazz    需要转换成的Bean
@return 返回一个封装好的Bean类实例，封装失败返回null
350889
public static <T> T toBean(Map<String, ?> property, Class<T> clazz) {
        T bean = null;
        try {
            bean = clazz.newInstance();
            BeanUtils.populate(bean, property);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return bean;
    }
904175
public static Map<String, PropertyDescriptor> mapPropertyDescriptors(Class<?> clazz) {
        PropertyDescriptor[] properties = propertyDescriptors(clazz);
        Map<String, PropertyDescriptor> mappedProperties = new HashMap<String, PropertyDescriptor>();

        for (PropertyDescriptor property : properties) {
            if ("class".equals(property.getName()) == false) {
                mappedProperties.put(property.getName(), property);
            }
        }

        return mappedProperties;
    }
550066
@SuppressWarnings("unchecked")
    public static <K, V> V[] mapToArray(Map<K, V> map, Class<V> clazz) {
        if (Checker.isNotEmpty(map)) {
            V[] array = (V[]) Array.newInstance(clazz, map.size());
            int i = 0;
            for (V v : map.values()) {
                array[i++] = v;
            }
            return array;
        }
        return null;
    }
211180
public static <T> T getProperty(Object bean, String name, Class<T> clazz) throws Exception {
        Method method = ReflectUtils.getPropertyGetterMethod(bean.getClass(), name);
        if (method.isAccessible()) {
            return (T) method.invoke(bean);
        } else {
            try {
                method.setAccessible(true);
                return (T) method.invoke(bean);
            } finally {
                method.setAccessible(false);
            }
        }
    }
1401
public static Properties getFieldsAsProperties(Object obj, Class<?>[] clazzes) throws Exception {
        Properties props = new Properties();
        for (Field field : obj.getClass().getDeclaredFields()) {
            if (Modifier.isStatic(field.getModifiers()))
                continue;
            field.setAccessible(true);
            Class<?> type = field.getType();
            if (clazzes == null || contains(type, clazzes)) {
                Object val = field.get(obj);
                if (val != null)
                    props.put(field.getName(), val.toString());

            }
        }

        return props;
    }
326264
public Boolean getAsBoolean(String property) {
		if (super.has(property)) {
			return get(property).getAsBoolean();
		}
		return null;
	}
1139640
public static Method findProperty(Class<?> clazz, String name) {
    	assert clazz != null;
    	assert name != null;
        Class<?> entityClass = clazz;
        while (entityClass != null) {
            Method[] methods = (entityClass.isInterface() ? entityClass.getMethods() : entityClass.getDeclaredMethods());
            for (Method method : methods) {
                if (method.getName().equals("get"+ StringUtils.capitalize(name)) ||
                    method.getName().equals("is"+ StringUtils.capitalize(name))) {
                    return method;
                }
            }
            entityClass = entityClass.getSuperclass();
        }
        return null;
    }
990901
public static boolean isNotPojo(Class<?> clazz) throws NullPointerException {
        Assert.notNull(clazz, "clazz不能为null");
        return Boolean.class.isAssignableFrom(clazz) || Character.class.isAssignableFrom(clazz)
               || Number.class.isAssignableFrom(clazz) || Map.class.isAssignableFrom(clazz)
               || String.class.isAssignableFrom(clazz) || Collection.class.isAssignableFrom(clazz)
               || Enum.class.isAssignableFrom(clazz) || isGeneralType(clazz);
    }
946429
public static Collection beanMap(String property, Collection c) {
        return beanMap(property, c.iterator(), false);
    }
994617
private Map<String, Class<?>> createPropertyMap(Class<?> clz) throws Exception
   {
      Map<String, Class<?>> result = new HashMap<>();

      for (Method m : clz.getMethods())
      {
         if (m.getName().startsWith("set"))
         {
            if (m.getReturnType().equals(Void.TYPE) &&
                m.getParameterCount() == 1 &&
                isSupported(m.getParameterTypes()[0]))
               result.put(m.getName().substring(3), m.getParameterTypes()[0]);
         }
      }
      
      return result;
   }
38716
public static Object get(final Object bean, final String property) {

        try {
            if (property.indexOf(".") >= 0) {

                final Object subBean = ClassMockUtils.get(bean, property.substring(0, property.indexOf(".")));

                if (subBean == null) {

                    return null;
                }

                final String newProperty = property.substring(property.indexOf(".") + 1);

                return ClassMockUtils.get(subBean, newProperty);
            }

            Method method = null;

            try {
                method = bean.getClass().getMethod(ClassMockUtils.propertyToGetter(property), new Class[] {});
            } catch (final NoSuchMethodException e) {
                method = bean.getClass().getMethod(ClassMockUtils.propertyToGetter(property, true), new Class[] {});
            }

            return method.invoke(bean, new Object[] {});

        } catch (final Exception e) {

            throw new RuntimeException("Can't get property " + property + " in the class " + bean.getClass().getName(), e);
        }
    }
742082
@SuppressWarnings({ "unchecked", "rawtypes" })
    public <T extends AbstractSchemaProperty> Set<T> get(final Class<T> clazz) {
        return (Set<T>) properties.get(clazz);
    }
1185501
public static <T> T getBean(Class<T> clazz) {
        ApplicationContext appContext = getAppContext();
        
        try {
            return appContext == null ? null : appContext.getBean(clazz);
        } catch (Exception e) {
            return null;
        }
    }
863787
public Object find(Class clazz, Object identifier) {
        try {
            return persistenceManager.findById(clazz, identifier);
        } catch (InitializationException ignore){}
        catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }
744600
public <T> T convert(Object object, Class<T> clazz) {
        if (object == null) {
            return null;
        }

        return mapper.convertValue(object, clazz);
    }
1245664
public static Map<String, PropertyDescriptor> getPropertyDescriptorMap(Class<?> clazz, boolean ignoreCase) throws BeanException {
		Map<String, PropertyDescriptor> map = BeanInfoCache.INSTANCE.getPropertyDescriptorMap(clazz, ignoreCase);
		if (null == map) {
			map = internalGetPropertyDescriptorMap(clazz, ignoreCase);
			BeanInfoCache.INSTANCE.putPropertyDescriptorMap(clazz, map, ignoreCase);
		}
		return map;
	}
1105919
public <T> Mapping<T> getMapping(Class<T> clazz) {
        return (cache != null) ? cache.getMapping(clazz, annotationSet)
                : new Mapping<T>(clazz, annotationSet);
    }