Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956.

Also see the following revisions:

    ------------------------------------------------------------------------
    r471202 | scolebourne | 2006-11-04 06:21:44 -0800 (Sat, 04 Nov 2006) | 1 line
    
    Remove getCollection() - use covariant decorated()
    ------------------------------------------------------------------------


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@815102 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2009-09-15 05:56:45 +00:00
parent bdfea5682b
commit ede856f90c

View File

@ -35,8 +35,8 @@ import org.apache.commons.collections.iterators.UnmodifiableIterator;
*
* @author Stephen Colebourne
*/
public final class UnmodifiableSet
extends AbstractSerializableSetDecorator
public final class UnmodifiableSet<E>
extends AbstractSerializableSetDecorator<E>
implements Unmodifiable {
/** Serialization version */
@ -48,11 +48,11 @@ public final class UnmodifiableSet
* @param set the set to decorate, must not be null
* @throws IllegalArgumentException if set is null
*/
public static Set decorate(Set set) {
public static <E> Set<E> decorate(Set<E> set) {
if (set instanceof Unmodifiable) {
return set;
}
return new UnmodifiableSet(set);
return new UnmodifiableSet<E>(set);
}
//-----------------------------------------------------------------------
@ -62,20 +62,20 @@ public final class UnmodifiableSet
* @param set the set to decorate, must not be null
* @throws IllegalArgumentException if set is null
*/
private UnmodifiableSet(Set set) {
private UnmodifiableSet(Set<E> set) {
super(set);
}
//-----------------------------------------------------------------------
public Iterator iterator() {
return UnmodifiableIterator.decorate(getCollection().iterator());
public Iterator<E> iterator() {
return UnmodifiableIterator.<E>decorate(decorated().iterator());
}
public boolean add(Object object) {
public boolean add(E object) {
throw new UnsupportedOperationException();
}
public boolean addAll(Collection coll) {
public boolean addAll(Collection<? extends E> coll) {
throw new UnsupportedOperationException();
}
@ -87,11 +87,11 @@ public final class UnmodifiableSet
throw new UnsupportedOperationException();
}
public boolean removeAll(Collection coll) {
public boolean removeAll(Collection<?> coll) {
throw new UnsupportedOperationException();
}
public boolean retainAll(Collection coll) {
public boolean retainAll(Collection<?> coll) {
throw new UnsupportedOperationException();
}