01: package org.apache.commons.events.observable;
02:
03: import java.util.Set;
04:
05: /**
06: * <p>
07: * Decorates a <code>Set</code> implementation with a <b>bound
08: * property</b> named "collection".
09: * </p>
10: * <p>
11: * Each modifying method call made on this <code>Set</code> is
12: * handled as a change to the "collection" property. This
13: * facility serves to notify subscribers of a change to the set
14: * but does not allow users the option of vetoing the change. To
15: * gain the ability to veto the change, use a {@link ConstrainedSet}
16: * decorater.
17: * </p>
18: * @see BoundCollection
19: * @since Commons Events 1.0
20: * @author Stephen Colebourne, Bryce Nordgren
21: */
22: public class BoundSet extends BoundCollection implements Set {
23: // Constructors
24: //-----------------------------------------------------------------------
25: protected BoundSet(final Set source,
26: final CollectionChangeEventFactory eventFactory) {
27:
28: super (source, eventFactory);
29: }
30:
31: protected BoundSet(final Set source) {
32: super (source);
33: }
34:
35: // Factory methods
36: //-----------------------------------------------------------------------
37: /**
38: * Factory method to decorate an existing Set with a bound
39: * "collection" property and a user-specified
40: * event factory.
41: * @param source The Set to decorate by wrapping (not copying).
42: * @param eventFactory The event factory to use when producing events.
43: * @return The bound set.
44: * @throws IllegalArgumentException if the source null
45: */
46: public static BoundSet decorate(final Set source,
47: final CollectionChangeEventFactory eventFactory) {
48: return new BoundSet(source, eventFactory);
49: }
50:
51: /**
52: * Factory method to decorate an existing Set with a bound
53: * "collection" property and the default
54: * event factory.
55: * @param source The Set to decorate by wrapping (not copying).
56: * @return The bound set.
57: * @throws IllegalArgumentException if the source null
58: */
59: public static BoundSet decorate(final Set source) {
60: return new BoundSet(source);
61: }
62: }
|