[Discussion & Question] Confusion about the use case where clazz != headClass in ClassUtils#declaredExcelContentProperty
#919
bengbengbalabalabeng
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Parameter Description:
clazz:actual data typeheadClass:configuration data typeIn the
ClassUtils#declaredExcelContentPropertymethod, there exists logic that allows theheadClassandclazzto be inconsistent, and theExcelContentPropertyobject defined byclazzwill override the one fromheadClass.To understand the applicable scenarios of this design, I tried the following two patterns that trigger
clazz != headClass, but found that neither produced the expected results in actual execution.1. Parent/Child Class Pattern
Model Definition:
Run Test
Result: The
@ExcelPropertyor@ExcelIgnoresetting in the subclass is invalid, and the header in the Excel file remains "Super NAME".The logic of
headNameListandignorehas already been processed when theExcelHeadProperty#initColumnPropertiesmethod callsClassUtils#declaredFields. Here, onlyExcelSuperModel( =headClass) is always processed, without considering the annotations ofExcelModel( =clazz) at all.2. Interface/Implementation Class Pattern
Model Definition:
Run Test
Result:
@ExcelPropertysetting is completely ineffective, and the exported Excel does not contain headers at all.Question
Both of the above will trigger the logic of
clazz != headClass, but the results do not meet expectations.Therefore, what I want to explore is:
headClassmust be strictly consistent with theclazz, is the merge/overwrite logic inClassUtils#doGetExcelContentPropertyforclazz != headClassredundant?clazz != headClasslogic?Beta Was this translation helpful? Give feedback.
All reactions