Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-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 | */ |
| 16 | package org.onosproject.config.model; |
| 17 | |
| 18 | import java.util.LinkedHashMap; |
| 19 | |
| 20 | /** |
| 21 | * Hollow definition of DataNode for ConfigService APIs. |
| 22 | */ |
| 23 | public interface DataNode { |
| 24 | //will remove this when the corresponding changes in onos-yang-tools become available |
| 25 | |
| 26 | /** |
| 27 | * Builder for DataNode. |
| 28 | */ |
| 29 | interface Builder<V> { |
| 30 | /** |
| 31 | * clones a base Data node obj to a new one. |
| 32 | * |
| 33 | * @param base base DataNode obj to be cloned |
| 34 | * @return a DataNode builder |
| 35 | */ |
| 36 | Builder addBaseObj(DataNode base); |
| 37 | /** |
| 38 | * Adds the value of the instance node. |
| 39 | * |
| 40 | * @param key of the node |
| 41 | * @return a DataNode builder |
| 42 | */ |
| 43 | Builder addKey(NodeKey key); |
| 44 | /** |
| 45 | * Adds the value of the instance node. |
| 46 | * |
| 47 | * @param type of the node |
| 48 | * @return a DataNode builder |
| 49 | */ |
| 50 | Builder addType(DataNode.Type type); |
| 51 | /** |
| 52 | * Adds the value of the leaf node. |
| 53 | * |
| 54 | * @param value at the node |
| 55 | * @return a DataNode builder |
| 56 | */ |
| 57 | Builder addValue(String value); |
| 58 | |
| 59 | /** |
| 60 | * Adds children to the children field. |
| 61 | * |
| 62 | * @param children to be added |
| 63 | * @return a DataNode builder |
| 64 | */ |
| 65 | //Builder addChildren(LinkedHashMap<NodeKey, DataNode> children); |
| 66 | |
| 67 | /** |
| 68 | * Builds an immutable DataNode entity. |
| 69 | * |
| 70 | * @return DataNode |
| 71 | */ |
| 72 | DataNode build(); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Returns the children if DataNode contains an inner node. |
| 77 | * |
| 78 | * @return LinkedHashMap of children for an inner node, null for a leaf node |
| 79 | */ |
| 80 | LinkedHashMap<NodeKey, DataNode> children(); |
| 81 | |
| 82 | /** |
| 83 | * Returns the value at the leaf node as a string. |
| 84 | * |
| 85 | * @return value at the leaf node as a string, null if it is an innernode |
| 86 | */ |
| 87 | String value(); |
| 88 | |
| 89 | /** |
| 90 | * Returns the node schema identifier. |
| 91 | * |
| 92 | * @return node schema identifier |
| 93 | */ |
| 94 | SchemaIdentifier identifier(); |
| 95 | |
| 96 | /** |
| 97 | * Returns the type of node. |
| 98 | * |
| 99 | * @return node type |
| 100 | */ |
| 101 | Type type(); |
| 102 | |
| 103 | /** |
| 104 | * Returns the key to identify a branching node. |
| 105 | * |
| 106 | * @return key to identify a branching node |
| 107 | */ |
| 108 | NodeKey key(); |
| 109 | |
| 110 | /** |
| 111 | * Represents type of node in data store. |
| 112 | */ |
| 113 | enum Type { |
| 114 | |
| 115 | /** |
| 116 | * Single instance node. |
| 117 | */ |
| 118 | SINGLE_INSTANCE_NODE, |
| 119 | |
| 120 | /** |
| 121 | * Multi instance node. |
| 122 | */ |
| 123 | MULTI_INSTANCE_NODE, |
| 124 | |
| 125 | /** |
| 126 | * Single instance leaf node. |
| 127 | */ |
| 128 | SINGLE_INSTANCE_LEAF_VALUE_NODE, |
| 129 | |
| 130 | /** |
| 131 | * Multi instance leaf node. |
| 132 | */ |
| 133 | MULTI_INSTANCE_LEAF_VALUE_NODE |
| 134 | } |
| 135 | } |