+ /**
+ * This method was initially added to {@link CdmBase} to fix #5161.
+ * It can be overridden by subclasses such as {@link IdentifiableEntity}
+ * to explicitly initialize listeners. This is needed e.g. after de-serialization
+ * as listeners are not serialized due to the @Transient annotation.
+ * However, it can be generally used for other use-cases as well
+ */
+ public void initListener() {}
+
+ /**
+ * Adds an item to a set of <code>this</code> object and fires the according
+ * {@link PropertyChangeEvent}. Workaround as long as add and remove is not yet
+ * implemented in aspectJ.
+ * @param set the set the new item is added to
+ * @param newItem the new item to be added to the set
+ * @param propertyName the name of the set as property in <code>this</code> object
+ */
+ protected <T extends CdmBase> void addToSetWithChangeEvent(Set<T> set, T newItem, String propertyName ){
+ Set<T> oldValue = new HashSet<T>(set);
+ set.add(newItem);
+ firePropertyChange(new PropertyChangeEvent(this, propertyName, oldValue, set));
+ }
+
+ /**
+ * Removes an item from a set of <code>this</code> object and fires the according
+ * {@link PropertyChangeEvent}. Workaround as long as add and remove is not yet
+ * implemented in aspectJ.
+ * @param set the set the item is to be removed from
+ * @param itemToRemove the item to be removed from the set
+ * @param propertyName the name of the set as property in <code>this</code> object