Author: bayard
Date: Tue Sep 15 05:54:03 2009
New Revision: 815015
URL: http://svn.apache.org/viewvc?rev=815015&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
------------------------------------------------------------------------
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/SynchronizedBag.java
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/SynchronizedBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/SynchronizedBag.java?rev=815015&r1=815014&r2=815015&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/SynchronizedBag.java
(original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/SynchronizedBag.java
Tue Sep 15 05:54:03 2009
@@ -36,8 +36,8 @@
*
* @author Stephen Colebourne
*/
-public class SynchronizedBag
- extends SynchronizedCollection implements Bag {
+public class SynchronizedBag<E>
+ extends SynchronizedCollection<E> implements Bag<E> {
/** Serialization version */
private static final long serialVersionUID = 8084674570753837109L;
@@ -49,8 +49,8 @@
* @return a new synchronized Bag
* @throws IllegalArgumentException if bag is null
*/
- public static Bag decorate(Bag bag) {
- return new SynchronizedBag(bag);
+ public static <T> Bag<T> decorate(Bag<T> bag) {
+ return new SynchronizedBag<T>(bag);
}
//-----------------------------------------------------------------------
@@ -60,7 +60,7 @@
* @param bag the bag to decorate, must not be null
* @throws IllegalArgumentException if bag is null
*/
- protected SynchronizedBag(Bag bag) {
+ protected SynchronizedBag(Bag<E> bag) {
super(bag);
}
@@ -71,7 +71,7 @@
* @param lock the lock to use, must not be null
* @throws IllegalArgumentException if bag is null
*/
- protected SynchronizedBag(Bag bag, Object lock) {
+ protected SynchronizedBag(Bag<E> bag, Object lock) {
super(bag, lock);
}
@@ -80,12 +80,12 @@
*
* @return the decorated bag
*/
- protected Bag getBag() {
- return (Bag) collection;
+ protected Bag<E> getBag() {
+ return (Bag<E>) collection;
}
//-----------------------------------------------------------------------
- public boolean add(Object object, int count) {
+ public boolean add(E object, int count) {
synchronized (lock) {
return getBag().add(object, count);
}
@@ -97,9 +97,9 @@
}
}
- public Set uniqueSet() {
+ public Set<E> uniqueSet() {
synchronized (lock) {
- Set set = getBag().uniqueSet();
+ Set<E> set = getBag().uniqueSet();
return new SynchronizedBagSet(set, lock);
}
}
@@ -114,13 +114,16 @@
/**
* Synchronized Set for the Bag class.
*/
- class SynchronizedBagSet extends SynchronizedSet {
+ class SynchronizedBagSet extends SynchronizedSet<E> {
+ /** Serialization version */
+ private static final long serialVersionUID = 2990565892366827855L;
+
/**
* Constructor.
* @param set the set to decorate
* @param lock the lock to use, shared with the bag
*/
- SynchronizedBagSet(Set set, Object lock) {
+ SynchronizedBagSet(Set<E> set, Object lock) {
super(set, lock);
}
}
|