Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956.
Also see the following revisions: ------------------------------------------------------------------------ r555925 | skestle | 2007-07-13 03:39:24 -0700 (Fri, 13 Jul 2007) | 2 lines Added Edwin Tellman's patch for COLLECTIONS-243. It all seems pretty reasonable, and it should all be checked again as the project is worked through ------------------------------------------------------------------------ r471202 | scolebourne | 2006-11-04 06:21:44 -0800 (Sat, 04 Nov 2006) | 1 line Remove getCollection() - use covariant decorated() ------------------------------------------------------------------------ r471186 | scolebourne | 2006-11-04 05:47:51 -0800 (Sat, 04 Nov 2006) | 1 line Remove getSet() and getSortedSet() - use decorated() ------------------------------------------------------------------------ git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@815103 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ede856f90c
commit
be26bc6f09
|
@ -39,8 +39,8 @@ import org.apache.commons.collections.iterators.UnmodifiableIterator;
|
|||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
public final class UnmodifiableSortedSet
|
||||
extends AbstractSortedSetDecorator
|
||||
public final class UnmodifiableSortedSet<E>
|
||||
extends AbstractSortedSetDecorator<E>
|
||||
implements Unmodifiable, Serializable {
|
||||
|
||||
/** Serialization version */
|
||||
|
@ -52,11 +52,11 @@ public final class UnmodifiableSortedSet
|
|||
* @param set the set to decorate, must not be null
|
||||
* @throws IllegalArgumentException if set is null
|
||||
*/
|
||||
public static SortedSet decorate(SortedSet set) {
|
||||
public static <T> SortedSet<T> decorate(SortedSet<T> set) {
|
||||
if (set instanceof Unmodifiable) {
|
||||
return set;
|
||||
}
|
||||
return new UnmodifiableSortedSet(set);
|
||||
return new UnmodifiableSortedSet<T>(set);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -78,6 +78,7 @@ public final class UnmodifiableSortedSet
|
|||
* @throws IOException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
collection = (Collection) in.readObject();
|
||||
|
@ -90,20 +91,20 @@ public final class UnmodifiableSortedSet
|
|||
* @param set the set to decorate, must not be null
|
||||
* @throws IllegalArgumentException if set is null
|
||||
*/
|
||||
private UnmodifiableSortedSet(SortedSet set) {
|
||||
private UnmodifiableSortedSet(SortedSet<E> set) {
|
||||
super(set);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
public Iterator iterator() {
|
||||
return UnmodifiableIterator.decorate(getCollection().iterator());
|
||||
public Iterator<E> iterator() {
|
||||
return UnmodifiableIterator.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();
|
||||
}
|
||||
|
||||
|
@ -115,28 +116,28 @@ public final class UnmodifiableSortedSet
|
|||
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();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
public SortedSet subSet(Object fromElement, Object toElement) {
|
||||
SortedSet sub = getSortedSet().subSet(fromElement, toElement);
|
||||
return new UnmodifiableSortedSet(sub);
|
||||
public SortedSet<E> subSet(E fromElement, E toElement) {
|
||||
SortedSet<E> sub = decorated().subSet(fromElement, toElement);
|
||||
return new UnmodifiableSortedSet<E>(sub);
|
||||
}
|
||||
|
||||
public SortedSet headSet(Object toElement) {
|
||||
SortedSet sub = getSortedSet().headSet(toElement);
|
||||
return new UnmodifiableSortedSet(sub);
|
||||
public SortedSet<E> headSet(E toElement) {
|
||||
SortedSet<E> sub = decorated().headSet(toElement);
|
||||
return new UnmodifiableSortedSet<E>(sub);
|
||||
}
|
||||
|
||||
public SortedSet tailSet(Object fromElement) {
|
||||
SortedSet sub = getSortedSet().tailSet(fromElement);
|
||||
return new UnmodifiableSortedSet(sub);
|
||||
public SortedSet<E> tailSet(E fromElement) {
|
||||
SortedSet<E> sub = decorated().tailSet(fromElement);
|
||||
return new UnmodifiableSortedSet<E>(sub);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue