获取属性(得到泛型⾥的class类型对象)
import flect.Field;
import flect.ParameterizedType;
import flect.Type;
import java.util.*;
public class AnalysisObjUtil {
private final List<String> classTypeList;
public AnalysisObjUtil() {
this.classTypeList = new ArrayList<>();
this.classTypeList.add("byte");
this.classTypeList.add(TypeName());
this.classTypeList.add("short");
this.classTypeList.add(TypeName());
this.classTypeList.add("int");
频尿
this.classTypeList.add(TypeName());
this.classTypeList.add("long");
this.classTypeList.add(TypeName());
this.classTypeList.add("float");
this.classTypeList.add(TypeName());
this.classTypeList.add("double");
this.classTypeList.add(TypeName());
this.classTypeList.add("char");
this.classTypeList.add(TypeName());
一日十回this.classTypeList.add("boolean");
this.classTypeList.add(TypeName());
this.classTypeList.add(TypeName());
}
甘蔗的功效与作用是什么public LinkedHashMap<String, Object> scanField(Object obj) throws NoSuchFieldException, IllegalAccessException, InstantiationException { LinkedHashMap<String, Object> map = new LinkedHashMap<>();
LinkedHashMap<String, String> fieldNameAndTypeMap = FieldNameAndTypeMap(obj);
Set<String> keySet = fieldNameAndTypeMap.keySet();
for (String fieldName : keySet) {
String fieldType = (fieldName);
if (ains(fieldType)) {
map.put(fieldName, fieldType);
} el {
诛仙结局//如果不是Java⼋⼤类型和其包装类(有可能是集合,或者Map)
数学日记500字
Field field = FieldByName(obj, fieldName);
改变作文if (field == null) throw new IllegalArgumentException();
Class<?> type = Type();
if (type.equals(List.class)) {
爱你万年
Type genericType = GenericType();
if (genericType instanceof ParameterizedType) {
ParameterizedType pt = (ParameterizedType) genericType;
/
/ 得到泛型⾥的class类型对象
Class<?> genericClass = (Class<?>) pt.getActualTypeArguments()[0];
Object genericObj = wInstance();
List<Map<String, Object>> tmpMap = new ArrayList<>();
tmpMap.add(scanField(genericObj));
map.put(fieldName, tmpMap);
}
}
}
}
return map;
}
}
public LinkedHashMap<String, String> getFieldNameAndTypeMap(Object obj) {
LinkedHashMap<String, String> map = new LinkedHashMap<>();
Class<?> aClass = Class();
Field[] fields = DeclaredFields();
for (Field field : fields) {
field.tAccessible(true);
map.Name(), Type().getTypeName());
}
泰迪熊狗return map;
}
public Field getFieldByName(Object obj, String name) throws NoSuchFieldException { Class().getDeclaredField(name);
}
}