Add LithiumSR1 input/output support
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / QNameFactory.java
index 5c465e0e6f51602b16217dc06f9a505a62bdbd00..a0d8a311f7c32fc0ec23fc7bda455cba78fa36cc 100644 (file)
@@ -14,12 +14,14 @@ import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
 import java.net.URI;
 import java.util.Objects;
+import java.util.concurrent.ExecutionException;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 
 public final class QNameFactory {
     private static final class StringQName implements Immutable {
@@ -151,6 +153,13 @@ public final class QNameFactory {
                     return key.toQNameModule().intern();
                 }
             });
+    private static final LoadingCache<ModuleQName, NodeIdentifier> NODEID_CACHE = CacheBuilder.newBuilder()
+            .maximumSize(MAX_QNAME_CACHE_SIZE).weakValues().build(new CacheLoader<ModuleQName, NodeIdentifier>() {
+                @Override
+                public NodeIdentifier load(final ModuleQName key) throws ExecutionException {
+                    return NodeIdentifier.create(QNAME_CACHE.get(key));
+                }
+            });
 
     private QNameFactory() {
 
@@ -172,4 +181,9 @@ public final class QNameFactory {
     public static QNameModule createModule(final String namespace, final @Nullable String revision) {
         return MODULE_CACHE.getUnchecked(new StringModule(namespace, revision));
     }
+
+    public static @NonNull NodeIdentifier getNodeIdentifier(final QNameModule module, final String localName)
+            throws ExecutionException {
+        return NODEID_CACHE.get(new ModuleQName(module, localName));
+    }
 }