package com.gci.boot.common.util;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public final class ClassReflectionUtil {
    public static List<Field> getAllFields(Class<?> clazz) {
        List<Field> fieldList = new ArrayList<>();
        while (clazz != null && !"java.lang.Object".equals(clazz.getName())) {
            fieldList.addAll(Arrays.asList(clazz.getDeclaredFields()));
            clazz = clazz.getSuperclass();
        }
        return fieldList;
    }

    public static List<Method> getAllMethods(Class<?> clazz) {
        List<Method> methodList = new ArrayList<>();
        while (clazz != null && !"java.lang.Object".equals(clazz.getName())) {
            methodList.addAll(Arrays.asList(clazz.getDeclaredMethods()));
            clazz = clazz.getSuperclass();
        }
        return methodList;
    }
}
