Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -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.netconf; |
| 17 | |
| 18 | import static com.google.common.base.Preconditions.checkArgument; |
| 19 | |
| 20 | import org.onlab.util.Identifier; |
| 21 | |
| 22 | /** |
| 23 | * Identifier object to specify datastore. |
| 24 | */ |
| 25 | public class DatastoreId extends Identifier<String> { |
| 26 | |
| 27 | /** |
| 28 | * A configuration datastore holding |
| 29 | * the complete configuration currently active on the device. The |
| 30 | * running configuration datastore always exists. |
| 31 | */ |
| 32 | public static final DatastoreId RUNNING = datastore("running"); |
| 33 | |
| 34 | /** |
| 35 | * A configuration datastore that |
| 36 | * can be manipulated without impacting the device's current |
| 37 | * configuration and that can be committed to the running |
| 38 | * configuration datastore. Not all devices support a candidate |
| 39 | * configuration datastore. |
| 40 | */ |
| 41 | public static final DatastoreId CANDIDATE = datastore("candidate"); |
| 42 | |
| 43 | /** |
| 44 | * The configuration datastore |
| 45 | * holding the configuration loaded by the device when it boots. |
| 46 | * Only present on devices that separate the startup configuration |
| 47 | * datastore from the running configuration datastore. |
| 48 | */ |
| 49 | public static final DatastoreId STARTUP = datastore("startup"); |
| 50 | |
| 51 | /** |
| 52 | * Returns datastore identifier object. |
| 53 | * |
| 54 | * @param name of the datastore |
| 55 | * @return identifier |
| 56 | */ |
| 57 | public static DatastoreId datastore(String name) { |
| 58 | return new DatastoreId(name); |
| 59 | } |
| 60 | |
| 61 | DatastoreId(String name) { |
| 62 | super(name); |
| 63 | checkArgument(!name.isEmpty()); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Returns datastore name as XML tag. |
| 68 | * @return xml tag |
| 69 | */ |
| 70 | public String asXml() { |
| 71 | return "<" + id() + "/>"; |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public final String toString() { |
| 76 | return id(); |
| 77 | } |
| 78 | |
| 79 | } |