com.alibaba.excel.annotation.ExcelProperty Java Examples

The following examples show how to use com.alibaba.excel.annotation.ExcelProperty. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClassUtils.java    From easyexcel with Apache License 2.0 6 votes vote down vote up
private static void declaredOneField(Field field, Map<Integer, List<Field>> orderFiledMap,
    Map<Integer, Field> indexFiledMap, Map<String, Field> ignoreMap, ExcelIgnoreUnannotated excelIgnoreUnannotated,
    Boolean convertAllFiled) {
    ExcelIgnore excelIgnore = field.getAnnotation(ExcelIgnore.class);
    if (excelIgnore != null) {
        ignoreMap.put(field.getName(), field);
        return;
    }
    ExcelProperty excelProperty = field.getAnnotation(ExcelProperty.class);
    boolean noExcelProperty = excelProperty == null
        && ((convertAllFiled != null && !convertAllFiled) || excelIgnoreUnannotated != null);
    if (noExcelProperty) {
        ignoreMap.put(field.getName(), field);
        return;
    }
    boolean isStaticFinalOrTransient =
        (Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()))
            || Modifier.isTransient(field.getModifiers());
    if (excelProperty == null && isStaticFinalOrTransient) {
        ignoreMap.put(field.getName(), field);
        return;
    }
    if (excelProperty != null && excelProperty.index() >= 0) {
        if (indexFiledMap.containsKey(excelProperty.index())) {
            throw new ExcelCommonException("The index of '" + indexFiledMap.get(excelProperty.index()).getName()
                + "' and '" + field.getName() + "' must be inconsistent");
        }
        indexFiledMap.put(excelProperty.index(), field);
        return;
    }

    int order = Integer.MAX_VALUE;
    if (excelProperty != null) {
        order = excelProperty.order();
    }
    List<Field> orderFiledList = orderFiledMap.get(order);
    if (orderFiledList == null) {
        orderFiledList = new ArrayList<Field>();
        orderFiledMap.put(order, orderFiledList);
    }
    orderFiledList.add(field);
}