[COLLECTIONS-496] UnmodifiableBoundedCollection does now also implement the Unmodifiable marker interface.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1540766 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
72784c46f6
commit
539be680cd
|
@ -47,6 +47,8 @@ Major changes since 3.2.1
|
|||
Changes since 4.0-alpha1
|
||||
------------------------
|
||||
|
||||
o [COLLECTIONS-496] "UnmodifiableBoundedCollection" does now also implement the marker interface "Unmodifiable"
|
||||
similar as all other unmodifiable decorators.
|
||||
o [COLLECTIONS-495] "UnmodifiableTrie#unmodifiableTrie(Trie)" will not decorate again an already unmodifiable Trie.
|
||||
Also the return type has been changed to "Trie" to be consistent with other Unmodifiable decorators.
|
||||
o [COLLECTIONS-494] Moved "Equator" interface to base package for consistency. Thanks to Emmanuel Bourg.
|
||||
|
@ -161,6 +163,8 @@ New features
|
|||
Changed classes / methods
|
||||
-------------------------
|
||||
|
||||
o [COLLECTIONS-496] "UnmodifiableBoundedCollection" does now also implement the marker interface "Unmodifiable"
|
||||
similar as all other unmodifiable decorators.
|
||||
o [COLLECTIONS-495] "UnmodifiableTrie#unmodifiableTrie(Trie)" will not decorate again an already unmodifiable Trie.
|
||||
Also the return type has been changed to "Trie" to be consistent with other Unmodifiable decorators.
|
||||
o [COLLECTIONS-494] Moved "Equator" interface to base package for consistency. Thanks to Emmanuel Bourg.
|
||||
|
|
|
@ -38,6 +38,10 @@ Commons Collections is Java 5.
|
|||
Users are encouraged to upgrade to this version as, in addition to new
|
||||
features, this release includes numerous bug fixes.
|
||||
">
|
||||
<action issue="COLLECTIONS-496" dev="tn" type="update">
|
||||
"UnmodifiableBoundedCollection" does now also implement the marker interface "Unmodifiable"
|
||||
similar as all other unmodifiable decorators.
|
||||
</action>
|
||||
<action issue="COLLECTIONS-495" dev="tn" type="fix">
|
||||
"UnmodifiableTrie#unmodifiableTrie(Trie)" will not decorate again an already
|
||||
unmodifiable Trie. Also the return type has been changed to "Trie" to be consistent
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.Collection;
|
|||
import java.util.Iterator;
|
||||
|
||||
import org.apache.commons.collections4.BoundedCollection;
|
||||
import org.apache.commons.collections4.Unmodifiable;
|
||||
import org.apache.commons.collections4.iterators.UnmodifiableIterator;
|
||||
|
||||
/**
|
||||
|
@ -40,7 +41,7 @@ import org.apache.commons.collections4.iterators.UnmodifiableIterator;
|
|||
* @version $Id$
|
||||
*/
|
||||
public final class UnmodifiableBoundedCollection<E> extends AbstractCollectionDecorator<E>
|
||||
implements BoundedCollection<E> {
|
||||
implements BoundedCollection<E>, Unmodifiable {
|
||||
|
||||
/** Serialization version */
|
||||
private static final long serialVersionUID = -7112672385450340330L;
|
||||
|
@ -55,6 +56,11 @@ public final class UnmodifiableBoundedCollection<E> extends AbstractCollectionDe
|
|||
* @since 4.0
|
||||
*/
|
||||
public static <E> BoundedCollection<E> unmodifiableBoundedCollection(final BoundedCollection<? extends E> coll) {
|
||||
if (coll instanceof Unmodifiable) {
|
||||
@SuppressWarnings("unchecked") // safe to upcast
|
||||
final BoundedCollection<E> tmpColl = (BoundedCollection<E>) coll;
|
||||
return tmpColl;
|
||||
}
|
||||
return new UnmodifiableBoundedCollection<E>(coll);
|
||||
}
|
||||
|
||||
|
|
|
@ -155,8 +155,10 @@ have changed.
|
|||
|
||||
<center><h3>Changed classes / methods</h3></center>
|
||||
<ul>
|
||||
<li>"UnmodifiableBoundedCollection" does now also implement the marker interface "Unmodifiable"
|
||||
similar as all other unmodifiable decorators.</li>
|
||||
<li>"UnmodifiableTrie#unmodifiableTrie(Trie)" will not decorate again an already unmodifiable Trie.
|
||||
Also the return type has been changed to "Trie" to be consistent with other Unmodifiable decorators.</li>
|
||||
Also the return type has been changed to "Trie" to be consistent with other Unmodifiable decorators.</li>
|
||||
<li>Moved "Equator" interface to base package for consistency.</li>
|
||||
<li>Accept wildcard input where possible, e.g. in copy-constructors, Unmodifiable* decorators and iterators.</li>
|
||||
<li>Narrow return type of "BidiMap#values()" to Set as the values are required to be unique.</li>
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Arrays;
|
|||
import java.util.Collection;
|
||||
|
||||
import org.apache.commons.collections4.BoundedCollection;
|
||||
import org.apache.commons.collections4.Unmodifiable;
|
||||
import org.apache.commons.collections4.list.FixedSizeList;
|
||||
|
||||
/**
|
||||
|
@ -43,7 +44,7 @@ public class UnmodifiableBoundedCollectionTest<E> extends AbstractCollectionTest
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<E> makeFullCollection() {
|
||||
public BoundedCollection<E> makeFullCollection() {
|
||||
final E[] allElements = getFullElements();
|
||||
final BoundedCollection<E> coll = FixedSizeList.<E>fixedSizeList(new ArrayList<E>(Arrays.asList(allElements)));
|
||||
return UnmodifiableBoundedCollection.unmodifiableBoundedCollection(coll);
|
||||
|
@ -80,4 +81,22 @@ public class UnmodifiableBoundedCollectionTest<E> extends AbstractCollectionTest
|
|||
public String getCompatibilityVersion() {
|
||||
return "4";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
public void testUnmodifiable() {
|
||||
assertTrue(makeObject() instanceof Unmodifiable);
|
||||
assertTrue(makeFullCollection() instanceof Unmodifiable);
|
||||
}
|
||||
|
||||
public void testDecorateFactory() {
|
||||
final BoundedCollection<E> coll = makeFullCollection();
|
||||
assertSame(coll, UnmodifiableBoundedCollection.unmodifiableBoundedCollection(coll));
|
||||
|
||||
try {
|
||||
UnmodifiableBoundedCollection.unmodifiableBoundedCollection(null);
|
||||
fail();
|
||||
} catch (final IllegalArgumentException ex) {}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue