package com.dsk.common.utils;

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

public class ReflectionUtils {

    /**
     * 获取全部属性 （追溯到所有顶级类）但不包括常量
     * 
     * @param object
     * @return
     */
    public static List<Field> getDeclaredField(Object object) {
        Class<?> clazz = object.getClass();
        return getDeclaredField(clazz);
    }

    public static List<Field> getDeclaredField(Class<?> clazz) {
		List<Field> fields = new ArrayList<Field>();
        for (; clazz != Object.class; clazz = clazz.getSuperclass()) {
            for (Field field : clazz.getDeclaredFields()) {
                switch (field.getModifiers()) {
                case 24:
                case 25:
                case 26:
                case 28:
                    continue;
                default:
                    fields.add(field);
                    break;
                }
            }
        }
        return fields;
	}
}
