what
见题思意
before
1. 定义 Set<Class<?>> 静态不可变常量
2. 把已知的数值类型 add
3. 获取 field.getType **数据**类型 tempClazz
4. 判断该 set 集合中是否存在 tempClazz
5. 。。。
now
/**
* @param targetClazz java.lang.reflect.Field 的数据类型 clazz。 getType 方法获取
* @return
*/
boolean isNumberType(Class<?> targetClazz) {
// 判断包装类
if (Number.class.isAssignableFrom(targetClazz)) {
return true;
}
// 判断原始类,过滤掉特殊的基本类型
if (targetClazz == boolean.class || targetClazz == char.class || targetClazz == void.class) {
return false;
}
return targetClazz.isPrimitive();
}