private List getElementMetadata(Class clazz){ List<Field> list = new ArrayList<>(); if (clazz.getSuperclass() != null && !clazz.getSuperclass().equals(Object.class)) { List<Field> sublist = getElementMetadata(clazz.getSuperclass()); for(Field field : sublist){ list.add(field); } } Field fields[] = clazz.getDeclaredFields(); for(Field field : fields){ list.add(field); } return list; }