指定したBeanのクラスのインスタンスを作成する。

@param clazz Beanのクラスタイプ。
@return Beanのインスタンス。
@throws SuperCsvReflectionException Beanのインスタンスの作成に失敗した場合。
504827
protected T instantiateBean(final Class<T> clazz) {
        
        final T bean;
        if( clazz.isInterface() ) {
            bean = BeanInterfaceProxy.createProxy(clazz);
        } else {
            try {
                bean = clazz.newInstance();
            } catch(InstantiationException e) {
                throw new SuperCsvReflectionException(String.format(
                    "error instantiating bean, check that %s has a default no-args constructor", clazz.getName()), e);
            } catch(IllegalAccessException e) {
                throw new SuperCsvReflectionException("error instantiating bean", e);
            }
        }
        
        return bean;
        
    }
984636
public <T> T toBeanWithCamelCase(T bean) {
		BeanUtil.fillBeanWithMap(this, bean, true, false);
		return bean;
	}
1029247
public static Reflect onClass(String clazz) throws Exception {
      return new Reflect(null, ReflectionUtils.getClassForName(clazz));
   }
817513
public static <T> T instance(Class<T> superClass) {
		// check overriden map first
		if (map.get(superClass) != null) {
			return (T) JK.newInstance(map.get(superClass));
		}
		try {
			return (T) context.getBean(superClass);
		} catch (NoSuchBeanDefinitionException ex) {
			// no bean difinition is there, so lets try to see of the class is already
			// concrete and
			// can be qualified to be returned
			if (!Modifier.isAbstract(superClass.getModifiers())) {
				return JK.newInstance(superClass.getName());
			} else {
				throw ex;
			}
		} catch (RuntimeException e) {
			dumpBeansNames();
			throw e;
		}
	}
58161
public static <T> List<T> handleWorkBookToBeans(Class<T> clazz, File file) throws ReadExcelException {
        List<T> beans = null;
        try {
            Workbook workbook = WorkbookFactory.create(file);
            beans = ReadExcelUtils.handleWorkBookToBeans(clazz, workbook);
            if (workbook != null) {
                workbook.close();
            }
        } catch (Exception e) {
            throw new ReadExcelException(e.getMessage());
        }
        return beans;
    }
226939
public static <T> T getBean(Class<T> clazz, final boolean isIgnoreError) {
		final T bean = ServletUtil.toBean(getServletRequest(), clazz, isIgnoreError);
		
		//注入MultipartFormData 中的参数
		final MultipartFormData multipart = getMultipart();
		if(null != multipart){
			final String beanName = StrUtil.lowerFirst(bean.getClass().getSimpleName());
			BeanUtil.fillBean(bean, new ValueProvider<String>(){
				@Override
				public Object value(String key, Type valueType) {
					String value = multipart.getParam(key);
					if (StrUtil.isEmpty(value)) {
						//使用类名前缀尝试查找值
						value = multipart.getParam(beanName + StrUtil.DOT + key);
						if(StrUtil.isEmpty(value)){
							//此处取得的值为空时跳过，包括null和""
							value = null;
						}
					}
					return value;
				}

				@Override
				public boolean containsKey(String key) {
					return null != multipart.getParam(key);
				}
			}, CopyOptions.create().setIgnoreError(isIgnoreError));
		}
		
		return bean;
	}
906640
public <T> T toBean(T bean, boolean isToCamelCase) {
		BeanUtil.fillBeanWithMap(this, bean, isToCamelCase, false);
		return bean;
	}
79265
protected void populateBean(final T resultBean, final String[] nameMapping, final CsvBindingErrors bindingErrors) {
        
        // map each column to its associated field on the bean
        for( int i = 0; i < nameMapping.length; i++ ) {
            final String fieldName = nameMapping[i];
            final Object fieldValue = processedColumns.get(i);
            
            // don't call a set-method in the bean if there is no name mapping for the column or no result to store
            if( fieldName == null || fieldValue == null || bindingErrors.hasFieldErrors(fieldName)) {
                continue;
            }
            
            // invoke the setter on the bean
            final Method setMethod = cache.getSetMethod(resultBean, fieldName, fieldValue.getClass());
            try {
                setMethod.invoke(resultBean, fieldValue);
                
            } catch(final Exception e) {
                throw new SuperCsvReflectionException(String.format("error invoking method %s()", setMethod.getName()), e);
            }
            
        }
        
    }
328705
public static Type[] getSupperGenericType(Class clazz) {
        ParameterizedType parameterizedType;
        if (clazz.getGenericInterfaces().length > 0) {//父类是interface, the super type is an interface.
            if (clazz.getGenericInterfaces()[0] instanceof ParameterizedType) {
                /*注意：有多个父接口时，这里是取第一个父接口
                  Attention: if multiple parents are defined, we only get the first one.*/
                parameterizedType = (ParameterizedType) clazz.getGenericInterfaces()[0];
            } else {
                return null;
            }
        } else {//父类是class, the super type is a class.
            if (clazz.getGenericSuperclass() instanceof ParameterizedType) {
                parameterizedType = (ParameterizedType) clazz.getGenericSuperclass();
            } else {
                return null;
            }
        }
        return parameterizedType.getActualTypeArguments();
    }
749699
public static BeanDesc getBeanDesc(Class<?> clazz) {
		BeanDesc beanDesc = BeanDescCache.INSTANCE.getBeanDesc(clazz);
		if (null == beanDesc) {
			beanDesc = new BeanDesc(clazz);
			BeanDescCache.INSTANCE.putBeanDesc(clazz, beanDesc);
		}
		return beanDesc;
	}
816720
private void resolveSuperclassFieldDependencies(final Object reference, final Class<?> clazz) {
        if (clazz.equals(Object.class)) {
            return;
        }

        final Class<?> superclass = clazz.getSuperclass();

        resolveSuperclassFieldDependencies(reference, superclass);

        if (Modifier.isAbstract(clazz.getModifiers()) || Modifier.isInterface(clazz.getModifiers())) {
            return;
        }

        final Bean<?> bean = beanManager.getBean(clazz);
        final Set<FieldInjectionPoint> injectionPoints = bean.fieldInjectionPoints;

        for (final FieldInjectionPoint injectionPoint : injectionPoints) {
            final Object injection = beanManager.getInjectableReference(injectionPoint);
            final Field field = injectionPoint.getAnnotated().getJavaMember();

            try {
                final Field declaredField = proxyClass.getDeclaredField(field.getName());

                if (!Reflections.matchInheritance(declaredField, field)) { // Hide
                    try {
                        field.set(reference, injection);
                    } catch (final Exception e) {
                        throw new RuntimeException(e);
                    }
                }
            } catch (final NoSuchFieldException ex) {
                throw new RuntimeException(ex);

            }
        }
    }
220002
public static BeanPropertyAccessor forClass(Class<?> clazz) {
        synchronized (cAccessors) {
            BeanPropertyAccessor bpa = cAccessors.get(clazz);
            if (bpa != null) {
                return bpa;
            }
            bpa = generate(clazz);
            cAccessors.put(clazz, bpa);
            return bpa;
        }
    }
242373
public FacesBackingBean getFacesBackingBeanInstance( Class beanClass )
        throws InstantiationException, IllegalAccessException
    {
        assert FacesBackingBean.class.isAssignableFrom( beanClass )
                : "Class " + beanClass.getName() + " does not extend " + FacesBackingBean.class.getName();
        return ( FacesBackingBean ) beanClass.newInstance();
    }
269197
public synchronized static TypeDesc forClass(Class<?> clazz) {
        if (clazz == null) {
            return null;
        }

        TypeDesc type = cClassesToInstances.get(clazz);
        if (type != null) {
            return type;
        }

        if (clazz.isArray()) {
            type = forClass(clazz.getComponentType()).toArrayType();
        }
        else if (clazz.isPrimitive()) {
            if (clazz == int.class) {
                type = INT;
            }
            if (clazz == boolean.class) {
                type = BOOLEAN;
            }
            if (clazz == char.class) {
                type = CHAR;
            }
            if (clazz == byte.class) {
                type = BYTE;
            }
            if (clazz == long.class) {
                type = LONG;
            }
            if (clazz == float.class) {
                type = FLOAT;
            }
            if (clazz == double.class) {
                type = DOUBLE;
            }
            if (clazz == short.class) {
                type = SHORT;
            }
            if (clazz == void.class) {
                type = VOID;
            }
        }
        else {
            String name = clazz.getName();
            type = intern(new ObjectType(generateDescriptor(name), name));
        }

        cClassesToInstances.put(clazz, type);
        return type;
    }
1060777
@SuppressWarnings("unchecked")
    public <P> P createBean(final Class<P> clazz) {
        return (P) beanFactory.create(clazz);
    }
188723
protected final CnvTfsObject
    lazyGetCnvTfsObject(final Class pClass) throws Exception {
    String beanName = getCnvTfsObjectName(pClass);
    @SuppressWarnings("unchecked")
    CnvTfsObject<Object> convrt = (CnvTfsObject<Object>)
      this.convertersMap.get(beanName);
    if (convrt == null) {
      convrt = new CnvTfsObject<Object>();
      convrt.setUtlReflection(getUtlReflection());
      convrt.setFieldsConvertersFatory(this);
      convrt.setFieldConverterNamesHolder(this.fieldConverterNamesHolder);
      convrt.setGettersRapiHolder(this.gettersRapiHolder);
      convrt.setSettersRapiHolder(this.settersRapiHolder);
      convrt.init(pClass);
      this.convertersMap.put(beanName, convrt);
    }
    return convrt;
  }
1355271
public <T> T getBean(@NonNull Class<T> cls) {
        return this.ioc.getBean(cls);
    }