01: package org.apache.commons.events.observable;
02:
03: import java.util.Comparator;
04:
05: import org.apache.commons.collections.SortedBag;
06:
07: public class BoundSortedBag extends BoundBag implements SortedBag {
08:
09: // Constructors
10: //-----------------------------------------------------------------------
11: protected BoundSortedBag(final SortedBag source,
12: final CollectionChangeEventFactory eventFactory) {
13:
14: super (source, eventFactory);
15: }
16:
17: protected BoundSortedBag(final SortedBag source) {
18: super (source);
19: }
20:
21: // Factory methods
22: //-----------------------------------------------------------------------
23: public static BoundSortedBag decorate(final SortedBag source,
24: final CollectionChangeEventFactory eventFactory) {
25:
26: return new BoundSortedBag(source, eventFactory);
27: }
28:
29: public static BoundSortedBag decorate(final SortedBag source) {
30: return new BoundSortedBag(source);
31: }
32:
33: // Utility methods
34: //-----------------------------------------------------------------------
35: private SortedBag getSortedBag() {
36: return (SortedBag) (getCollection());
37: }
38:
39: // SortedBag API (methods which do not change the collection)
40: //-----------------------------------------------------------------------
41: public Object first() {
42: return getSortedBag().first();
43: }
44:
45: public Object last() {
46: return getSortedBag().last();
47: }
48:
49: public Comparator comparator() {
50: return getSortedBag().comparator();
51: }
52:
53: }
|