1 16 package org.apache.commons.collections.bag; 17 18 import java.util.Comparator ; 19 20 import org.apache.commons.collections.Bag; 21 import org.apache.commons.collections.SortedBag; 22 23 37 public class SynchronizedSortedBag 38 extends SynchronizedBag implements SortedBag { 39 40 41 private static final long serialVersionUID = 722374056718497858L; 42 43 50 public static SortedBag decorate(SortedBag bag) { 51 return new SynchronizedSortedBag(bag); 52 } 53 54 61 protected SynchronizedSortedBag(SortedBag bag) { 62 super(bag); 63 } 64 65 72 protected SynchronizedSortedBag(Bag bag, Object lock) { 73 super(bag, lock); 74 } 75 76 81 protected SortedBag getSortedBag() { 82 return (SortedBag) collection; 83 } 84 85 public synchronized Object first() { 87 synchronized (lock) { 88 return getSortedBag().first(); 89 } 90 } 91 92 public synchronized Object last() { 93 synchronized (lock) { 94 return getSortedBag().last(); 95 } 96 } 97 98 public synchronized Comparator comparator() { 99 synchronized (lock) { 100 return getSortedBag().comparator(); 101 } 102 } 103 104 } 105 | Popular Tags |