Revision 479c80d3
Added by Andreas Müller almost 9 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/CdmBase.java | ||
---|---|---|
13 | 13 |
import java.beans.PropertyChangeSupport; |
14 | 14 |
import java.io.Serializable; |
15 | 15 |
import java.lang.reflect.Method; |
16 |
import java.util.HashSet; |
|
17 |
import java.util.Set; |
|
16 | 18 |
import java.util.UUID; |
17 | 19 |
|
18 | 20 |
import javax.persistence.Basic; |
... | ... | |
196 | 198 |
propertyChangeSupport.firePropertyChange(evt); |
197 | 199 |
} |
198 | 200 |
|
201 |
/** |
|
202 |
* Adds an item to a set of <code>this</code> object and fires the according |
|
203 |
* {@link PropertyChangeEvent}. Workaround as long as add and remove is not yet |
|
204 |
* implemented in aspectJ. |
|
205 |
* @param set the set the new item is added to |
|
206 |
* @param newItem the new item to be added to the set |
|
207 |
* @param propertyName the name of the set as property in <code>this</code> object |
|
208 |
*/ |
|
209 |
protected <T extends CdmBase> void addToSetWithChangeEvent(Set<T> set, T newItem, String propertyName ){ |
|
210 |
Set<T> oldValue = new HashSet<T>(set); |
|
211 |
set.add(newItem); |
|
212 |
firePropertyChange(new PropertyChangeEvent(this, propertyName, oldValue, set)); |
|
213 |
} |
|
214 |
|
|
215 |
/** |
|
216 |
* Removes an item from a set of <code>this</code> object and fires the according |
|
217 |
* {@link PropertyChangeEvent}. Workaround as long as add and remove is not yet |
|
218 |
* implemented in aspectJ. |
|
219 |
* @param set the set the item is to be removed from |
|
220 |
* @param itemToRemove the item to be removed from the set |
|
221 |
* @param propertyName the name of the set as property in <code>this</code> object |
|
222 |
*/ |
|
223 |
protected <T extends CdmBase> void removeFromSetWithChangeEvent(Set<T> set, T itemToRemove, String propertyName ){ |
|
224 |
Set<T> oldValue = new HashSet<T>(set); |
|
225 |
set.remove(itemToRemove); |
|
226 |
firePropertyChange(new PropertyChangeEvent(this, propertyName, oldValue, set)); |
|
227 |
} |
|
228 |
|
|
199 | 229 |
@Override |
200 | 230 |
public UUID getUuid() { |
201 | 231 |
return uuid; |
Also available in: Unified diff
improve handling of titlecache in terms #3148