Open JanecekPetr opened 1 year ago
A PR would be appreciated for this.
@JanecekPetr , you can use now unmodifiable views - see #154
@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.
Namely,
SortedSet
andNavigableSet
andSortedMap
andNavigableMap
. All of those have an unmodifiable wrapper available inCollections
. While not ideal and slightly worse than the actually immutable copies available viaList.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
toSortedSet
.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 :)