Sithara Punnassery | 589fac2 | 2016-10-03 11:51:53 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Sithara Punnassery | 589fac2 | 2016-10-03 11:51:53 -0700 | [diff] [blame] | 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.incubator.elasticcfg; |
| 17 | |
| 18 | import org.onlab.util.Identifier; |
| 19 | |
| 20 | import static com.google.common.base.Preconditions.checkNotNull; |
| 21 | |
| 22 | /** |
| 23 | * Abstraction of the key to an instance in the elastic config store. |
| 24 | * Path to each node would contain info about its hierarchy too. |
| 25 | */ |
| 26 | public final class ConfigNodePath extends Identifier<String> { |
| 27 | |
| 28 | private final String parentKey; |
| 29 | private final String nodeKey; |
| 30 | |
| 31 | /** |
| 32 | * Creates a new ConfigNodePath from parentKey and nodeKey. |
| 33 | * |
| 34 | * @param parentKey absolute path to the parent. |
| 35 | * @param nodeKey relative path to the node. |
| 36 | */ |
| 37 | public ConfigNodePath(String parentKey, String nodeKey) { |
| 38 | super(checkNotNull(parentKey, "parent key is null").concat(checkNotNull(nodeKey, "node key is null"))); |
| 39 | this.parentKey = parentKey; |
| 40 | this.nodeKey = nodeKey; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Returns the parent key. |
| 45 | * |
| 46 | * @return absolute path to the parent |
| 47 | */ |
| 48 | public String parentKey() { |
| 49 | return parentKey; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Returns the node key. |
| 54 | * |
| 55 | * @return relative path to the node |
| 56 | */ |
| 57 | public String nodeKey() { |
| 58 | return nodeKey; |
| 59 | } |
| 60 | } |