brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [2/3] incubator-brooklyn git commit: use better EntityConfigMap.filterUninherited method, from @aledsage code review
Date Thu, 29 Jan 2015 11:35:45 GMT
use better EntityConfigMap.filterUninherited method, from @aledsage code review


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/9613dd11
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/9613dd11
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/9613dd11

Branch: refs/heads/master
Commit: 9613dd11b07d69a8f30145d16ce2d255c22ede20
Parents: 2939e80
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Thu Jan 29 11:33:46 2015 +0000
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Thu Jan 29 11:34:34 2015 +0000

----------------------------------------------------------------------
 .../brooklyn/entity/basic/EntityConfigMap.java   | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9613dd11/core/src/main/java/brooklyn/entity/basic/EntityConfigMap.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/EntityConfigMap.java b/core/src/main/java/brooklyn/entity/basic/EntityConfigMap.java
index dd7a933..c4efe7c 100644
--- a/core/src/main/java/brooklyn/entity/basic/EntityConfigMap.java
+++ b/core/src/main/java/brooklyn/entity/basic/EntityConfigMap.java
@@ -22,7 +22,6 @@ import static brooklyn.util.GroovyJavaMethods.elvis;
 import static com.google.common.base.Preconditions.checkNotNull;
 
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Set;
@@ -38,7 +37,6 @@ import brooklyn.config.ConfigMap;
 import brooklyn.event.basic.StructuredConfigKey;
 import brooklyn.management.ExecutionContext;
 import brooklyn.management.Task;
-import brooklyn.util.collections.MutableList;
 import brooklyn.util.collections.MutableMap;
 import brooklyn.util.config.ConfigBag;
 import brooklyn.util.flags.FlagUtils;
@@ -298,19 +296,16 @@ public class EntityConfigMap implements ConfigMap {
         }
     }
     
-    private Map<ConfigKey<?>, ?> filterUninheritable(Map<ConfigKey<?>,
?> valsO) {
-        MutableMap<ConfigKey<?>, Object> result = MutableMap.copyOf(valsO);
-        MutableList<ConfigKey<?>> keys = MutableList.copyOf(result.keySet());
-        Iterator<ConfigKey<?>> ki = keys.iterator();
-        while (ki.hasNext()) {
-            ConfigKey<?> key = ki.next();
-            if (isInherited(key)) ki.remove();
+    private Map<ConfigKey<?>, ?> filterUninheritable(Map<ConfigKey<?>,
?> vals) {
+        Map<ConfigKey<?>, Object> result = Maps.newLinkedHashMap();
+        for (Map.Entry<ConfigKey<?>, ?> entry : vals.entrySet()) {
+            if (isInherited(entry.getKey())) {
+                result.put(entry.getKey(), entry.getValue());
+            }
         }
-        for (ConfigKey<?> k: keys)
-            result.remove(k);
         return result;
     }
-
+    
     public void addToLocalBag(Map<String,?> vals) {
         localConfigBag.putAll(vals);
         // quick fix for problem that ownConfig can get out of synch


Mime
View raw message