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

Support more Collection (and Map) types for immutable collections #151

Open
JanecekPetr opened this issue Apr 5, 2023 · 3 comments
Open
Labels
enhancement New feature or request good first issue Good for newcomers PR welcome A PR submitted for this issue would be welcome

Comments

@JanecekPetr
Copy link

Namely, SortedSet and NavigableSet and SortedMap and NavigableMap. All of those have an unmodifiable wrapper available in Collections. While not ideal and slightly worse than the actually immutable copies available via List.copyOf and friends, it's way better to have an unmodifiable wrapper (and a collection initialized to empty when nothing is in) than having null.

This was really surprising to consistently get empty collections everywhere and suddenly there was a null because we changed a Set to SortedSet.

In a perfect world, there would be support for even more types, like what Immutables do: Multisets and Multimaps from Guava, BiMap, all ImmutableCollections, EnumMaps. But let's not jump there yet :)

@Randgalt
Copy link
Owner

A PR would be appreciated for this.

@Randgalt Randgalt added the PR welcome A PR submitted for this issue would be welcome label Apr 11, 2023
@pawellabaj
Copy link
Contributor

@JanecekPetr , you can use now unmodifiable views - see #154

@pawellabaj
Copy link
Contributor

@JanecekPetr workaround proposal: use AutoRecord with ARICE extension.

It supports the most important (all ?) interfaces from java.util and com.google.common.collect packages.
However, it requires a Guava library for generated records, so it won't suit everyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers PR welcome A PR submitted for this issue would be welcome
Projects
None yet
Development

No branches or pull requests

3 participants