blob: 7b7f5bda1aa6845fee0c294abcc5d0944f3fd68c [file] [log] [blame]
Sithara Punnassery4b091dc2017-03-02 17:22:40 -08001/*
2 * Copyright 2017-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.config;
17
18import java.util.Iterator;
19import org.onosproject.yang.model.NodeKey;
20import org.onosproject.yang.model.ResourceId;
21
22/**
23 * Representation of an entity which identifies a resource in the logical tree
24 * data store. It is a list of node keys to identify the branch point
25 * hierarchy to reach a resource in the instance tree.
26 */
27
28public final class ResourceIdParser {
29
30 private ResourceIdParser() {
31
32 }
33 public static String asString(ResourceId path) {
34 StringBuilder bldr = new StringBuilder();
35 bldr.append("root.");
36 Iterator<NodeKey> iter = path.nodeKeys().iterator();
37 NodeKey key;
38 while (iter.hasNext()) {
39 key = iter.next();
40 //log.info("Iter: key {}", key.toString());
41 bldr.append(key.schemaId().name());
42 bldr.append("#");
43 bldr.append(key.schemaId().namespace());
44 if (iter.hasNext()) {
45 bldr.append(".");
46 }
47 }
48 return bldr.toString();
49 }
50}