X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-protocolbuffer-encoding%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fnode%2Futils%2FNodeIdentifierFactory.java;h=175e242a11eedc3803e3722139d0b860832aabf7;hb=516a4b2ea78179c9bd6ebb584862e8fc686ebf08;hp=3250fadcf57dff837bcd396e1ef3c956049fc589;hpb=f1c47fb514878ef2149e5f22d6098ff8c79dec1d;p=controller.git diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactory.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactory.java index 3250fadcf5..175e242a11 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactory.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactory.java @@ -1,19 +1,20 @@ package org.opendaylight.controller.cluster.datastore.node.utils; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import java.util.HashMap; import java.util.Map; public class NodeIdentifierFactory { - private static final Map cache = new HashMap<>(); - public static InstanceIdentifier.PathArgument getArgument(String id){ - InstanceIdentifier.PathArgument value = cache.get(id); + private static final Map cache = new HashMap<>(); + public static YangInstanceIdentifier.PathArgument getArgument(String id){ + YangInstanceIdentifier.PathArgument value = cache.get(id); if(value == null){ synchronized (cache){ value = cache.get(id); if(value == null) { - value = createPathArgument(id); + value = createPathArgument(id, null); cache.put(id, value); } } @@ -21,15 +22,29 @@ public class NodeIdentifierFactory { return value; } - private static InstanceIdentifier.PathArgument createPathArgument(String id){ + public static YangInstanceIdentifier.PathArgument getArgument(String id, DataSchemaNode schemaNode){ + YangInstanceIdentifier.PathArgument value = cache.get(id); + if(value == null){ + synchronized (cache){ + value = cache.get(id); + if(value == null) { + value = createPathArgument(id, schemaNode); + cache.put(id, value); + } + } + } + return value; + } + + public static YangInstanceIdentifier.PathArgument createPathArgument(String id, DataSchemaNode schemaNode){ final NodeIdentifierWithPredicatesGenerator - nodeIdentifierWithPredicatesGenerator = new NodeIdentifierWithPredicatesGenerator(id); + nodeIdentifierWithPredicatesGenerator = new NodeIdentifierWithPredicatesGenerator(id, schemaNode); if(nodeIdentifierWithPredicatesGenerator.matches()){ return nodeIdentifierWithPredicatesGenerator.getPathArgument(); } final NodeIdentifierWithValueGenerator - nodeWithValueGenerator = new NodeIdentifierWithValueGenerator(id); + nodeWithValueGenerator = new NodeIdentifierWithValueGenerator(id, schemaNode); if(nodeWithValueGenerator.matches()){ return nodeWithValueGenerator.getPathArgument(); }