Skip to content

Java21 SequencedCollection::getFirst support #4082

Description

@jbidet-adis

Expected behavior

Support for the list.getFirst() getter in @Mapping(target="...", source="list.first")
And handler for the NoSuchElementException thrown by this method if SequencedCollection is empty.

Note : getFirst was introduced in java 21

Actual behavior

Unknown property 'first' :
Image

Impl :
Image

Steps to reproduce the problem

Any mapping with a SequencedCollection impl (i.e. List)
Use "list.first" as source
Mapper will show 'first' in red
Pass an empty list to the mapper, you'll get an NSEE

MapStruct Version

1.6.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions