us.codecraft.webmagic.utils.ClassUtils Maven / Gradle / Ivy
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;
}
}