views:

69

answers:

1

I'd like to put unmodifiable wrappers around some of the Trove collections: I've checked the Trove documentation and I cannot seem to find an easy way to do it (I may have overlooked something obvious).

So as of now every time I need such an unmodifiable wrapper I'm extending the Trove collection (for example TIntLongHashMap) and delegating all the read-only calls to the Trove wrapped subject and throwing an UnsupportedOperationException in every method that tries to modify the collection.

Is there an easier way?

Note: this question is not about the default Java collections and, in this case, I'm not interested at all neither in the default Java collections nor in other Java collections: this question is specifically about Trove.

+1  A: 

There is no way to do this with the Trove API, only with the decorators.

bmargulies