Content-Length: 290381 | pFad | http://github.com/mapstruct/mapstruct/pull/3356

55 #3334: Support returning unmodifiable collections and maps by j-be · Pull Request #3356 · mapstruct/mapstruct · GitHub
Skip to content

#3334: Support returning unmodifiable collections and maps #3356

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

j-be
Copy link

@j-be j-be commented Aug 6, 2023

With the introduction of record into the language, immutable datatypes are a great way to move stuff around in Java in an efficient and safe (as in thread-safe) way.

Providing immutable - or in Java terms: unmodifiable - collections provides another piece to the puzzle.

This PR introduces a new annotation, @Unmodifiable, which if put on apstract mapper methods lets them return unmodifiable collections.

Fixes #3334

@filiphr filiphr self-requested a review March 3, 2024 12:34
@filiphr
Copy link
Member

filiphr commented Mar 3, 2024

Thanks for your work on this @j-be. I managed to review it and it is a really good direction. There are some things that are still missing:

  • Need support for mapping Stream to List, Collection etc. (this is part of the StreamMappingMethod
  • We need error handling for mapping to types that do not support unmodifiable e.g. if you do @IterableMapping(unmodifiable = true) when the return type is ArrayList or some other type of collection that cannot be called on Collections.unmodifiableXXX then we need to have a compile error from MapStruct instead of leaving the compile error on the generated code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to map Collections to Immutable Lists
2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/mapstruct/mapstruct/pull/3356

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy