diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/common-java/src/main/java')
-rw-r--r-- | sca-java-2.x/trunk/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CollectionMap.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/sca-java-2.x/trunk/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CollectionMap.java b/sca-java-2.x/trunk/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CollectionMap.java index cc3fb4676d..0db80c891d 100644 --- a/sca-java-2.x/trunk/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CollectionMap.java +++ b/sca-java-2.x/trunk/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CollectionMap.java @@ -48,13 +48,28 @@ public class CollectionMap<K, V> extends ConcurrentHashMap<K, Collection<V>> { } public boolean removeValue(K key, V value) { + return removeValue(key, value, false); + } + + /** + * Remove an entry from the collection for a key + * @param key The key + * @param value The value in the collection + * @param removeEmptyEntry Indicate if the entry should be removed if the collection is empty + * @return + */ + public boolean removeValue(K key, V value, boolean removeEmptyEntry) { Collection<V> collection = get(key); if (collection == null) { return false; } - return collection.remove(value); + boolean result = collection.remove(value); + if(removeEmptyEntry && collection.isEmpty()) { + remove(key); + } + return result; } - + protected Collection<V> createCollection() { return new ArrayList<V>(); } |