Skip to content

Kotlin data class support for FlatFileItemReaderBuilder #4568

Closed as not planned
@0x1306e6d

Description

@0x1306e6d

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: declinedFeatures that we don't intend to implement or Bug reports that are invalid or missing enough detailstype: feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions