blob: b0df547adb544d52ea73935dfac075b03aca6cbd [file] [log] [blame]
Yuta HIGUCHI89111d92017-05-04 11:29:17 -07001/*
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.netconf;
17
18import static com.google.common.base.Preconditions.checkArgument;
19
20import org.onlab.util.Identifier;
21
22/**
23 * Identifier object to specify datastore.
24 */
25public 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}