Use cached AugmentationIdentifiers in BindingRuntimeContext 52/82352/2
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 31 May 2019 10:55:50 +0000 (12:55 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 31 May 2019 11:47:21 +0000 (13:47 +0200)
AugmentationIdentifiers allocated from BindingRuntimeContext
end up being used across the system. This ensures we squash
instances to system-wide cache.

Change-Id: I0d75dc8815f86cb1dda13ef118ceb9b6455a31e3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingRuntimeContext.java

index 564bca20895d6a5378cf5265f9be6df73b6102fa..dc2be63654c51fae21ba35f6c892dab8ae01ee2d 100644 (file)
@@ -18,6 +18,7 @@ import com.google.common.cache.LoadingCache;
 import com.google.common.collect.BiMap;
 import com.google.common.collect.HashBiMap;
 import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 import java.util.AbstractMap.SimpleEntry;
 import java.util.ArrayList;
@@ -438,11 +439,9 @@ public final class BindingRuntimeContext implements Immutable {
     }
 
     private static AugmentationIdentifier getAugmentationIdentifier(final AugmentationSchemaNode augment) {
-        final Set<QName> childNames = new HashSet<>();
-        for (final DataSchemaNode child : augment.getChildNodes()) {
-            childNames.add(child.getQName());
-        }
-        return new AugmentationIdentifier(childNames);
+        // FIXME: use DataSchemaContextNode.augmentationIdentifierFrom() once it does caching
+        return AugmentationIdentifier.create(augment.getChildNodes().stream().map(DataSchemaNode::getQName)
+            .collect(ImmutableSet.toImmutableSet()));
     }
 
     private static Type referencedType(final Class<?> type) {