1 package org.opendaylight.controller.cluster.datastore.node.utils;
3 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
4 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
6 import java.util.HashMap;
9 public class NodeIdentifierFactory {
10 private static final Map<String, YangInstanceIdentifier.PathArgument> cache = new HashMap<>();
11 public static YangInstanceIdentifier.PathArgument getArgument(String id){
12 YangInstanceIdentifier.PathArgument value = cache.get(id);
15 value = cache.get(id);
17 value = createPathArgument(id, null);
25 public static YangInstanceIdentifier.PathArgument getArgument(String id, DataSchemaNode schemaNode){
26 YangInstanceIdentifier.PathArgument value = cache.get(id);
29 value = cache.get(id);
31 value = createPathArgument(id, schemaNode);
39 public static YangInstanceIdentifier.PathArgument createPathArgument(String id, DataSchemaNode schemaNode){
40 final NodeIdentifierWithPredicatesGenerator
41 nodeIdentifierWithPredicatesGenerator = new NodeIdentifierWithPredicatesGenerator(id, schemaNode);
42 if(nodeIdentifierWithPredicatesGenerator.matches()){
43 return nodeIdentifierWithPredicatesGenerator.getPathArgument();
46 final NodeIdentifierWithValueGenerator
47 nodeWithValueGenerator = new NodeIdentifierWithValueGenerator(id, schemaNode);
48 if(nodeWithValueGenerator.matches()){
49 return nodeWithValueGenerator.getPathArgument();
52 final AugmentationIdentifierGenerator augmentationIdentifierGenerator = new AugmentationIdentifierGenerator(id);
53 if(augmentationIdentifierGenerator.matches()){
54 return augmentationIdentifierGenerator.getPathArgument();
57 return new NodeIdentifierGenerator(id).getArgument();