You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ba...@apache.org on 2009/09/15 07:56:46 UTC
svn commit: r815103 -
/commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java
Author: bayard
Date: Tue Sep 15 05:56:46 2009
New Revision: 815103
URL: http://svn.apache.org/viewvc?rev=815103&view=rev
Log:
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()
------------------------------------------------------------------------
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java?rev=815103&r1=815102&r2=815103&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java Tue Sep 15 05:56:46 2009
@@ -39,8 +39,8 @@
*
* @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 @@
* @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 @@
* @throws IOException
* @throws ClassNotFoundException
*/
+ @SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
collection = (Collection) in.readObject();
@@ -90,20 +91,20 @@
* @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 @@
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);
}
}