In addition to supporting the standard Java property change notification interfaces, TM4J uses a separate interface for notifying changes to potentially large collections. This interface is the org.tm4j.utils.MultiValuePropertyChangeListener interface. The interface supports only a single notification method multiValuePropertyChange() which receives a single paramter of the type org.tm4j.utils.MultiValuePropertyChangeEvent. Unlike a standard java.beans.PropertyChangeEvent, the MultiValuePropertyChangeEvent class describes the change to a collection as a combination of an operation and an operand. The different operations that can be notified are listed in the table below. The type of the operand depends upon a combination of the operation performed and the property that was modified.
Table 5.2. MultiValuePropertyChangeEvent operation types
Operation Constant | Notified When | Operand |
---|---|---|
OP_ADD_SINGLE | A single object has been added to the collection property. | The object that was added to the collection property. |
OP_ADD_SET | A collection of objects has been added to the collection property. | The collection of objects added. |
OP_REMOVE_SINGLE | A single object has been removed from the collection property. | The object that has been removed. |
OP_REMOVE_SET | A collection of objects have been removed from the collection property. | The collection of objects removed. |
The following table shows which property changes are notified through this mechanism, and what the object type of the property is. In the case of OP_ADD_SINGLE and OP_REMOVE_SINGLE, the operand will be an object of the specified object type. In the case of OP_ADD_SET and OP_REMOVE_SET, the operand will always be a java.util.Collection containing objects of the specified object type.