If Read-only set/UnmodifiableSet doesn't implement the Set interface, you won't be able to use it for functions with arguments of type Set. You won't be able to cast back to a Set because a ReadOnlySet isn't a type of Set.
The only way this would work is if java.util.Set extended ReadOnlySet/UnmodifiableSet, and that will probably never happen. On Mar 24, 2017 8:57 AM, "Lukasz Lenart" <lukaszlen...@apache.org> wrote: > 2017-03-23 16:55 GMT+01:00 Javen O'Neal <javenon...@gmail.com>: > > The best solution is to document where you return an UnmodifiableSet > versus > > a regular Set in your Javadocs. > > Disagree, compare these two examples: > > /** > * An immutable set, do not try to modify it > */ > private Set<String> excluded; > > vs > > private UnmodifiableSet<String> excluded; > > > Regards > -- > Ćukasz > + 48 606 323 122 http://www.lenart.org.pl/ > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > >