blob: c608038781f2c8f0186f56a6576f4265cd4591a7 [file] [log] [blame]
Ai Hamanobd51cdd2018-10-18 11:30:07 +09001/*
2 * Copyright 2018-present Open Networking Foundation
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.odtn.utils.openconfig;
17
18import org.onosproject.yang.gen.v1.openconfigterminaldevice.rev20161222.openconfigterminaldevice.terminallogicalchanassignmenttop.logicalchannelassignments.DefaultAssignment;
19
20import org.onosproject.yang.model.KeyLeaf;
21
22/**
23 * Utility class to deal with OPENCONFIG Assignment ModelObject & Annotation.
24 */
25public final class OpenConfigAssignmentHandler
26 extends OpenConfigObjectHandler<DefaultAssignment> {
27
28 private static final String OPENCONFIG_NAME = "assignment";
29 private static final String KEY_LEAF_NAME = "index";
30 private static final String NAME_SPACE = "http://openconfig.net/yang/terminal-device";
31
32 /**
33 * OpenConfigAssignmentHandler Constructor.
34 *
35 * @param keyValue String of target OPENCONFIG's key
36 * @param parent OpenConfigLogicalChannelAssignmentsHandler of
37 * parent OPENCONFIG(logical-channel-assignments)
38 */
39 public OpenConfigAssignmentHandler(String keyValue,
40 OpenConfigLogicalChannelAssignmentsHandler parent) {
41 modelObject = new DefaultAssignment();
42 modelObject.index(keyValue);
43 setResourceId(OPENCONFIG_NAME, NAME_SPACE,
44 new KeyLeaf(KEY_LEAF_NAME, NAME_SPACE, keyValue),
45 parent.getResourceIdBuilder());
46 annotatedNodeInfos = parent.getAnnotatedNodeInfoList();
47
48 parent.addAssignment(this);
49 }
50
51 /**
52 * Add Config to modelObject of target OPENCONFIG.
53 *
54 * @param config OpenConfigConfigOfAssignmentHandler having Config to be set for modelObject
55 * @return OpenConfigAssignmentHandler of target OPENCONFIG
56 */
57 public OpenConfigAssignmentHandler addConfig(OpenConfigConfigOfAssignmentHandler config) {
58 modelObject.config(config.getModelObject());
59 return this;
60 }
61}