Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin data class support for FlatFileItemReaderBuilder #4568

Open
0x1306e6d opened this issue Mar 27, 2024 · 0 comments
Open

Kotlin data class support for FlatFileItemReaderBuilder #4568

0x1306e6d opened this issue Mar 27, 2024 · 0 comments
Labels
status: waiting-for-triage Issues that we did not analyse yet type: feature

Comments

@0x1306e6d
Copy link

Please do a quick search on Github issues first, the feature you are about to request might have already been requested.

Expected Behavior

Make FlatFileItemReaderBuilder detect whether the target type is Kotlin data class and sets proper FieldSetMapper which is not BeanWrapperFieldSetMapper.

RecordFieldSetMapper works with a Kotlin data class but we might be better to introduce a new dedicated FieldSetMapper.

Current Behavior

The FlatFileItemReaderBuilder only detects whether the target type is record or not. So it sets the BeanWrapperFieldSetMapper which instantiates the target type by the default constructor (no-args) and causes NotWritablePropertyException:

if (this.targetType != null && this.targetType.isRecord()) {
RecordFieldSetMapper<T> mapper = new RecordFieldSetMapper<>(this.targetType);
lineMapper.setFieldSetMapper(mapper);
}
else {

Context

As a workaround, we might make the data class fields nullable and mutable like:

data class Player(var lastName: String? = null)

but as you know, it doesn't leverage the Kotlin's features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage Issues that we did not analyse yet type: feature
Projects
None yet
Development

No branches or pull requests

1 participant