commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Curdt <>
Subject [collections] UnmodifiableBoundedCollection
Date Wed, 31 Mar 2004 14:07:17 GMT
Quoting from the javadocs

> UnmodifiableBoundedCollection decorates another BoundedCollection  to
> ensure it can't be altered.
> If a BoundedCollection is first wrapped in some other collection 
> decorator, such as synchronized or predicated, the BoundedCollection 
> nature is lost. The factory on this class will attempt to retrieve the 
> bounded nature by examining the package scope variables. 

I wondered why this should be the case so I gave it a try:

         Map sm = MapUtils.synchronizedMap(new HashMap());
         Map m = MapUtils.fixedSizeMap(sm);

         Map m = MapUtils.fixedSizeMap(new HashMap());
         Map sm = MapUtils.synchronizedMap(m);

Both examples throw an exception as exspected.
Can someone explain why the UnmodifiableBoundedCollection
is needed?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message