From 318a7ad950353460e79d67533a406500bbacff81 Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Wed, 9 Feb 2022 14:31:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9B=AE=E5=BD=95=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../excel/metadata/AbstractHolder.java | 102 +++++++++++++++++- 1 file changed, 101 insertions(+), 1 deletion(-) diff --git a/easyexcel-core/src/main/java/com/alibaba/excel/metadata/AbstractHolder.java b/easyexcel-core/src/main/java/com/alibaba/excel/metadata/AbstractHolder.java index a83f64a5..839a8b4b 100644 --- a/easyexcel-core/src/main/java/com/alibaba/excel/metadata/AbstractHolder.java +++ b/easyexcel-core/src/main/java/com/alibaba/excel/metadata/AbstractHolder.java @@ -1,3 +1,103 @@ +package com.alibaba.excel.metadata; + +import java.util.List; +import java.util.Map; + +import com.alibaba.excel.converters.Converter; +import com.alibaba.excel.converters.ConverterKeyBuild.ConverterKey; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + /** - * Documents have been migrated to https://github.com/alibaba/easyexcel/blob/master/easyexcel-core/src/test/java/com/alibaba/easyexcel/test/demo/fill/FillTest.java + * Write/read holder + * + * @author Jiaju Zhuang */ +@Getter +@Setter +@EqualsAndHashCode +@NoArgsConstructor +public abstract class AbstractHolder implements ConfigurationHolder { + /** + * Record whether it's new or from cache + */ + private Boolean newInitialization; + /** + * You can only choose one of the {@link AbstractHolder#head} and {@link AbstractHolder#clazz} + */ + private List> head; + /** + * You can only choose one of the {@link AbstractHolder#head} and {@link AbstractHolder#clazz} + */ + private Class clazz; + /** + * Some global variables + */ + private GlobalConfiguration globalConfiguration; + /** + *

+ * Read key: + *

+ * Write key: + */ + private Map> converterMap; + + public AbstractHolder(BasicParameter basicParameter, AbstractHolder prentAbstractHolder) { + this.newInitialization = Boolean.TRUE; + if (basicParameter.getHead() == null && basicParameter.getClazz() == null && prentAbstractHolder != null) { + this.head = prentAbstractHolder.getHead(); + } else { + this.head = basicParameter.getHead(); + } + if (basicParameter.getHead() == null && basicParameter.getClazz() == null && prentAbstractHolder != null) { + this.clazz = prentAbstractHolder.getClazz(); + } else { + this.clazz = basicParameter.getClazz(); + } + this.globalConfiguration = new GlobalConfiguration(); + if (basicParameter.getAutoTrim() == null) { + if (prentAbstractHolder != null) { + globalConfiguration.setAutoTrim(prentAbstractHolder.getGlobalConfiguration().getAutoTrim()); + } + } else { + globalConfiguration.setAutoTrim(basicParameter.getAutoTrim()); + } + + if (basicParameter.getUse1904windowing() == null) { + if (prentAbstractHolder != null) { + globalConfiguration.setUse1904windowing( + prentAbstractHolder.getGlobalConfiguration().getUse1904windowing()); + } + } else { + globalConfiguration.setUse1904windowing(basicParameter.getUse1904windowing()); + } + + if (basicParameter.getLocale() == null) { + if (prentAbstractHolder != null) { + globalConfiguration.setLocale(prentAbstractHolder.getGlobalConfiguration().getLocale()); + } + } else { + globalConfiguration.setLocale(basicParameter.getLocale()); + } + + } + + @Override + public Map> converterMap() { + return getConverterMap(); + } + + @Override + public GlobalConfiguration globalConfiguration() { + return getGlobalConfiguration(); + } + + @Override + public boolean isNew() { + return getNewInitialization(); + } + +}