Android Class Field Find getFields(Class cs)

Here you can find the source of getFields(Class cs)

Description

get Fields

Declaration

public static Field[] getFields(Class<?> cs) 

Method Source Code

//package com.java2s;

import java.lang.reflect.Field;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static Field[] getFields(Class<?> cs) {
        List<Field> fieldList = new ArrayList<Field>();
        Class<?> c = cs;//from  ww w .  ja  v a 2s. com
        while (c != null) {
            Field[] fields = c.getDeclaredFields();
            for (Field field : fields) {
                fieldList.add(field);
            }
            c = c.getSuperclass();

        }
        return fieldList.toArray(new Field[fieldList.size()]);
    }
}

Related

  1. findField(Class clazz, String fieldName)
  2. findFieldRecursiveImpl(Class clazz, String fieldName)
  3. findFirstFieldByExactType(Class clazz, Class type)
  4. getAdditionalStaticField(Class clazz, String key)