hooj0 commented on PR #619:
URL: https://github.com/apache/fesod/pull/619#issuecomment-3395857401

   ## Purpose of the pull request
   
   <!-- Describe the purpose of this pull request. For example: Closed: 
#ISSUE-->
   增加泛型实现,获取当前行级数据记录对象。当前实现增加`getter`方法进行泛型输出,这样改动比较少。在使用行级对象的时候不需要进行强制类型转换。
   
   ## What's changed?
   
   <!--- Describe the change below, including rationale and design decisions -->
   + WriteConverterContext
     - `public <E extends Object> E getRecord() {
           return (E) record;
       }`
   + CellWriteHandlerContext
     - `public <E extends Object> E getOriginalRecord() {
           return (E) originalRecord;
       }`
   
   
   ### 测试代码
   + RecordStringStringConverter.java
   ```java
   @Override
       public WriteCellData<?> convertToExcelData(WriteConverterContext<String> 
context) {
           // 获取原始数据,不需要强制类型转换
           RecordData record = context.getRecord();
           log.debug("原始数据:{}", record);
           return new WriteCellData<>("自定义:" + context.getValue() + "-" + 
record.getDoubleData());
       }
   ```
   
   + RecordCellWriteHandler.java
   ```java
   @Override
       public void afterCellDispose(CellWriteHandlerContext context) {
           Cell cell = context.getCell();
   
           if (BooleanUtils.isFalse(context.getHead()) && cell.getColumnIndex() 
!= 0) {
               RecordData record = context.getOriginalRecord();
               log.info("写入数据:{}", record);
           }
       }
   ```
   
   ## Checklist
   
   - [x] I have read the [Contributor 
Guide](https://fesod.apache.org/community/contribution/).
   - [x] I have written the necessary doc or comment.
   - [x] I have added the necessary unit tests and all cases have passed.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to