3 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
11 package org.opendaylight.controller.cluster.datastore.node.utils;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
14 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
16 import java.util.HashMap;
19 public class NodeIdentifierFactory {
20 private static final Map<String, YangInstanceIdentifier.PathArgument> cache = new HashMap<>();
21 public static YangInstanceIdentifier.PathArgument getArgument(String id){
22 YangInstanceIdentifier.PathArgument value = cache.get(id);
25 value = cache.get(id);
27 value = createPathArgument(id, null);
35 public static YangInstanceIdentifier.PathArgument createPathArgument(String id, DataSchemaNode schemaNode){
36 final NodeIdentifierWithPredicatesGenerator
37 nodeIdentifierWithPredicatesGenerator = new NodeIdentifierWithPredicatesGenerator(id, schemaNode);
38 if(nodeIdentifierWithPredicatesGenerator.matches()){
39 return nodeIdentifierWithPredicatesGenerator.getPathArgument();
42 final NodeIdentifierWithValueGenerator
43 nodeWithValueGenerator = new NodeIdentifierWithValueGenerator(id, schemaNode);
44 if(nodeWithValueGenerator.matches()){
45 return nodeWithValueGenerator.getPathArgument();
48 final AugmentationIdentifierGenerator augmentationIdentifierGenerator = new AugmentationIdentifierGenerator(id);
49 if(augmentationIdentifierGenerator.matches()){
50 return augmentationIdentifierGenerator.getPathArgument();
53 return new NodeIdentifierGenerator(id).getArgument();