0
에 넣고 넣어방법 부모 클래스 개체에서 모든 자식 클래스 객체를 얻을지도 자바 봄에 어떻게 부모 클래스 개체에서 모든 자식 클래스 객체를 얻는지도 자바 스프링
public static Map<String, Object> ConvertObjectToMap(Object obj, Integer number) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
Class<?> pomclass = obj.getClass();
pomclass = obj.getClass();
Method[] methods = obj.getClass().getMethods();
Map<String, Object> map = new HashMap<String, Object>();
for (Method m : methods) {
if (m.getName().startsWith("get") && !m.getName().startsWith("getClass")) {
Object value = null;
value = (Object) m.invoke(obj);
if (number <= 1) {
if (value.getClass().isAnnotation()) {
map.putAll(ConvertObjectToMap(value, number++));
} else {
map.put(m.getName().substring(3), (Object) value);
}
}
}
}
return map;
}
이 맞습니까?
질문의 "지도 자바 봄에 넣어"부분을하지 않았다. – Arham
** ** ** 작동합니까? – ppeterka
맞습니까? 모르겠다. 너 정말로 무엇을하려고하는거야? –