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 getArgument(String id, DataSchemaNode schemaNode){
36 YangInstanceIdentifier.PathArgument value = cache.get(id);
39 value = cache.get(id);
41 value = createPathArgument(id, schemaNode);
49 public static YangInstanceIdentifier.PathArgument createPathArgument(String id, DataSchemaNode schemaNode){
50 final NodeIdentifierWithPredicatesGenerator
51 nodeIdentifierWithPredicatesGenerator = new NodeIdentifierWithPredicatesGenerator(id, schemaNode);
52 if(nodeIdentifierWithPredicatesGenerator.matches()){
53 return nodeIdentifierWithPredicatesGenerator.getPathArgument();
56 final NodeIdentifierWithValueGenerator
57 nodeWithValueGenerator = new NodeIdentifierWithValueGenerator(id, schemaNode);
58 if(nodeWithValueGenerator.matches()){
59 return nodeWithValueGenerator.getPathArgument();
62 final AugmentationIdentifierGenerator augmentationIdentifierGenerator = new AugmentationIdentifierGenerator(id);
63 if(augmentationIdentifierGenerator.matches()){
64 return augmentationIdentifierGenerator.getPathArgument();
67 return new NodeIdentifierGenerator(id).getArgument();