You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@fesod.apache.org by "nkuprins (via GitHub)" <gi...@apache.org> on 2026/08/05 22:55:53 UTC

Re: [D] [Discussion & Question] Confusion about the use case where `clazz` != `headClass` in `ClassUtils#declaredExcelContentProperty` [fesod]

GitHub user nkuprins added a comment to the discussion: [Discussion & Question] Confusion about the use case where `clazz` != `headClass` in `ClassUtils#declaredExcelContentProperty`

While checking this, I hit something that does look wrong:
```java
@Data 
class Super {
    @ExcelProperty("Super NAME") 
    @DateTimeFormat("yyyy") 
    Date name;
}

@EqualsAndHashCode(callSuper = true) 
@Data 
class Sub extends Super {
    @ExcelProperty("Sub NAME")
    @DateTimeFormat("yyyy-MM-dd") 
    Date name;  // shadows
    
    @ExcelProperty("CONTROL")    
    @DateTimeFormat("yyyy-MM-dd") 
    Date control; // nothing shadows this
}

FesodSheet.write(file, Sub.class).sheet().doWrite(listOfSub);
```

**Expected**

| Sub NAME | CONTROL |
|---|---|
| 2020-03-04 | 2020-03-04 |

**Actual**

| Sub NAME | CONTROL |
|---|---|
| **2020** | 2020-03-04 |

The cause seems to be in `doDeclaredFieldContentMap`: it walks from subclass to superclass but `put` unconditionally, so the superclass lands last and wins. This may be a fix then:
```java
if (!fieldContentMap.containsKey(field.getName())) {
    fieldContentMap.put(field.getName(), excelContentProperty);
}
```

GitHub link: https://github.com/apache/fesod/discussions/919#discussioncomment-17913251

----
This is an automatically sent email for dev@fesod.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@fesod.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@fesod.apache.org
For additional commands, e-mail: dev-help@fesod.apache.org