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();
}