Guava ImmutableSortedSetMultimap?
If you don't need extra meaning Multimap
, you have an indirect approach (I wrote the code in SO so it may not work, but there is an idea):
SortedSetMultimap<K,V> set = ...;
ImmutableMap<K, ImmutableSortedSet<V>> result = ImmutableMap.copyOf(Maps.transform(set.asMap(), new Function<SortedSet<V>, ImmutableSortedSet<V>>() {
public ImmutableSortedSet<V> apply(SortedSet<V> s) {
return ImmutableSortedSet.copyOf(s);
}
});
That is: turn yours SortedSetMultimap
into Map<K,SortedSet<V>>
, then Map<K,ImmutableSortedSet<V>>
, and then ImmutableMap
.
And I don't know enough Guava, but since it is ImmutableSetMultimap
immutable, the order of the copied set can remain: this means there is no need ImmutableSortedSetMultimap
for navigation / iteration (unless you require a specific method SortedSet
).
source to share
I was looking for this myself and just discovered this: Multimaps.unmodifiableSortedSetMultimap ()
Not what we're looking for, but good enough in my case.
source to share