Search in sources :

Example 1 with ExcelIgnoreUnannotated

use of com.alibaba.excel.annotation.ExcelIgnoreUnannotated in project easyexcel by alibaba.

the class ClassUtils method declaredFields.

private static FieldCache declaredFields(Class<?> clazz) {
    if (clazz == null) {
        return null;
    }
    return FIELD_CACHE.computeIfAbsent(clazz, key -> {
        List<Field> tempFieldList = new ArrayList<>();
        Class<?> tempClass = clazz;
        // level.
        while (tempClass != null) {
            Collections.addAll(tempFieldList, tempClass.getDeclaredFields());
            // Get the parent class and give it to yourself
            tempClass = tempClass.getSuperclass();
        }
        // Screening of field
        Map<Integer, List<Field>> orderFieldMap = new TreeMap<Integer, List<Field>>();
        Map<Integer, Field> indexFieldMap = new TreeMap<Integer, Field>();
        Map<String, Field> ignoreMap = new HashMap<String, Field>(16);
        ExcelIgnoreUnannotated excelIgnoreUnannotated = clazz.getAnnotation(ExcelIgnoreUnannotated.class);
        for (Field field : tempFieldList) {
            declaredOneField(field, orderFieldMap, indexFieldMap, ignoreMap, excelIgnoreUnannotated);
        }
        return new FieldCache(buildSortedAllFieldMap(orderFieldMap, indexFieldMap), indexFieldMap, ignoreMap);
    });
}
Also used : HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) Field(java.lang.reflect.Field) ExcelIgnoreUnannotated(com.alibaba.excel.annotation.ExcelIgnoreUnannotated) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ExcelIgnoreUnannotated (com.alibaba.excel.annotation.ExcelIgnoreUnannotated)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 TreeMap (java.util.TreeMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1