-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
When specifying record as the sourceType for FlatFileItemWriter, RecordFieldExtractor operates due to the following conditional statement.
if (this.sourceType != null && this.sourceType.isRecord()) {
this.fieldExtractor = new RecordFieldExtractor<>(this.sourceType);
}
RecordFieldExtractor internally calls targetType.getRecordComponents() to return the record's fields as RecordComponent.
In this process, the values specified in FormattedBuilder.names() are ignored.
It was confirmed that in the existing test FlatFileItemWriterBuilderTests.testSetupFormatterLineAggregatorWithRecordItemType(), even when arbitrary values are specified through names(), RecordFieldExtractor ignores the values specified in names() and properly retrieves the record's fields.


Therefore, if record is specified as the sourceType for FlatFileItemWriter, I think there is no need to call FormattedBuilder.names().
However, since the return type of FormattedBuilder.sourceType() is FormattedBuilder, in order to continue method chaining for FlatFileItemWriter, FormattedBuilder.fieldExtractor() or FormattedBuilder.names() must be called.
This appears to be an unnecessary process.