2 * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.cluster.datastore.node.utils;
11 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
12 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
14 import java.util.HashMap;
17 public class NodeIdentifierFactory {
18 private static final Map<String, YangInstanceIdentifier.PathArgument> cache = new HashMap<>();
19 public static YangInstanceIdentifier.PathArgument getArgument(String id){
20 YangInstanceIdentifier.PathArgument value = cache.get(id);
23 value = cache.get(id);
25 value = createPathArgument(id, null);
33 public static YangInstanceIdentifier.PathArgument createPathArgument(String id, DataSchemaNode schemaNode){
34 final NodeIdentifierWithPredicatesGenerator
35 nodeIdentifierWithPredicatesGenerator = new NodeIdentifierWithPredicatesGenerator(id, schemaNode);
36 if(nodeIdentifierWithPredicatesGenerator.matches()){
37 return nodeIdentifierWithPredicatesGenerator.getPathArgument();
40 final NodeIdentifierWithValueGenerator
41 nodeWithValueGenerator = new NodeIdentifierWithValueGenerator(id, schemaNode);
42 if(nodeWithValueGenerator.matches()){
43 return nodeWithValueGenerator.getPathArgument();
46 final AugmentationIdentifierGenerator augmentationIdentifierGenerator = new AugmentationIdentifierGenerator(id);
47 if(augmentationIdentifierGenerator.matches()){
48 return augmentationIdentifierGenerator.getPathArgument();
51 return new NodeIdentifierGenerator(id).getArgument();