| 217 | } |
| 218 | |
| 219 | static class SynchronizedCollection<T> implements Collection<T> { |
| 220 | protected final Object lock; |
| 221 | protected final Collection<T> collection; |
| 222 | |
| 223 | public SynchronizedCollection(Object lock, Collection<T> collection) { |
| 224 | this.lock = lock; |
| 225 | this.collection = collection; |
| 226 | } |
| 227 | |
| 228 | public int size() { |
| 229 | synchronized (lock) { return collection.size(); } |
| 230 | } |
| 231 | |
| 232 | public boolean isEmpty() { |
| 233 | return size() == 0; |
| 234 | } |
| 235 | |
| 236 | public boolean contains(Object e) { |
| 237 | synchronized (lock) { return collection.contains(e); } |
| 238 | } |
| 239 | |
| 240 | public boolean add(T e) { |
| 241 | synchronized (lock) { return collection.add(e); } |
| 242 | } |
| 243 | |
| 244 | public boolean addAll(Collection<? extends T> collection) { |
| 245 | synchronized (lock) { return this.collection.addAll(collection); } |
| 246 | } |
| 247 | |
| 248 | public boolean remove(Object e) { |
| 249 | synchronized (lock) { return collection.remove((T)e); } |
| 250 | } |
| 251 | |
| 252 | public Object[] toArray() { |
| 253 | return toArray(new Object[size()]); |
| 254 | } |
| 255 | |
| 256 | public <T> T[] toArray(T[] array) { |
| 257 | synchronized (lock) { return collection.toArray(array); } |
| 258 | } |
| 259 | |
| 260 | public void clear() { |
| 261 | synchronized (lock) { collection.clear(); } |
| 262 | } |
| 263 | |
| 264 | public Iterator<T> iterator() { |
| 265 | return new SynchronizedIterator<T>(lock, collection.iterator()); |
| 266 | } |
| 267 | |
| 268 | public boolean containsAll(Collection<?> c) { |
| 269 | synchronized (lock) { return collection.containsAll(c); } |
| 270 | } |
| 271 | |
| 272 | public boolean removeAll(Collection<?> c) { |
| 273 | synchronized (lock) { return collection.removeAll(c); } |
| 274 | } |
| 275 | } |
| 276 |
nothing calls this directly
no outgoing calls
no test coverage detected