When I try to implement my own ImmutableList
(actually a wrapper that delegates to the underlying list) I get the following compiler error:
ImmutableListWrapper is not abstract and does not override abstract method isPartialView() in com.google.common.collect.ImmutableCollection
But in fact, it seems to be impossible to override isPartialView()
because it is package protected and I'd like to declare the wrapper in my own package.
Why don't I simply extend ImmutableCollection
? Because I want ImmutableList.copyOf()
to return my instance without making a defensive copy.
The only approach I can think of is declaring a subclass in guava's package which changes isPartialView()
from package-protected to public, and then having my wrapper extend that. Is there a cleaner way?
What I am trying to do
I am attempting to fix https://github.com/google/guava/issues/2029 by creating a wrapper that would delegate to the underlying ImmutableList for all methods except spliterator()
, which would it override.
I am working under the assumption that users may define variables of type ImmutableList
and expect the the wrapper to be a drop-in replacement (i.e. it isn't enough to implement List
, they are expecting an ImmutableList
).