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

us.codecraft.webmagic.utils.ClassUtils Maven / Gradle / Ivy

The newest version!
package us.codecraft.webmagic.utils;

import java.lang.reflect.Field;
import java.util.LinkedHashSet;
import java.util.Set;

/**
 * @author [email protected]
 * @since 0.5.0
 */
public abstract class ClassUtils {

    public static Set getFieldsIncludeSuperClass(Class clazz) {
        Set fields = new LinkedHashSet();
        Class current = clazz;
        while (current != null) {
            Field[] currentFields = current.getDeclaredFields();
            for (Field currentField : currentFields) {
                fields.add(currentField);
            }
            current = current.getSuperclass();
        }
        return fields;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy