java.util.Collections
has several unmodifiable
methods that provide unmodifiable collection views by wrapping collections in decorators that prohibit mutation operations.
Java 6 added support for java.util.NavigableSet
and java.util.NavigableMap
.
I'd like to be able to have unmodifiable NavigableSet
s and NavigableMap
s, but java.util.Collections#unmodifiableSortedSet(SortedSet)
and java.util.Collections#unmodifiableSortedMap(SortedMap)
are not sufficient because they do not support the operations that are particular to NavigableSet
and NavigableMap
.
Are there de-facto implementations for unmodifiableNavigableSet
and unmodifiableNavigableMap
?
Guava now provides (since version 12.0, released April 30, 2012) Maps.unmodifiableNavigableMap and Sets.unmodifiableNavigableSet.
Java SE 8 included these two methods.
See the Javadoc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With