All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lq.comment.util.ClassUtil Maven / Gradle / Ivy

package com.lq.comment.util;

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

public class ClassUtil {

    private static final String objectType = "java.lang.Object";

    public static void getDeclaredFields(Class aClass, List declaredFieldList){
        Class superclass = aClass.getSuperclass();
        if (superclass.getName().equals(objectType)){
            Field[] declaredFields = aClass.getDeclaredFields();
            declaredFieldList.addAll(Arrays.asList(declaredFields));
        }else {
            Field[] declaredFields = aClass.getDeclaredFields();
            declaredFieldList.addAll(Arrays.asList(declaredFields));
            aClass = superclass;
            getDeclaredFields(aClass,declaredFieldList);
        }
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy