Ai Hamano | bd51cdd | 2018-10-18 11:30:07 +0900 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.odtn.utils.openconfig; |
| 17 | |
| 18 | import org.onosproject.yang.gen.v1.openconfigterminaldevice.rev20161222.openconfigterminaldevice.terminallogicalchanneltop.logicalchannels.DefaultChannel; |
| 19 | |
| 20 | import org.onosproject.yang.model.KeyLeaf; |
| 21 | |
| 22 | /** |
| 23 | * Utility class to deal with OPENCONFIG Channel ModelObject & Annotation. |
| 24 | */ |
| 25 | public final class OpenConfigChannelHandler |
| 26 | extends OpenConfigObjectHandler<DefaultChannel> { |
| 27 | |
| 28 | private static final String OPENCONFIG_NAME = "channel"; |
| 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 | * OpenConfigChannelHandler Constructor. |
| 34 | * |
| 35 | * @param keyValue String of target OPENCONFIG's key |
| 36 | * @param parent OpenConfigLogicalChannelsHandler of parent OPENCONFIG(logical-channels) |
| 37 | */ |
| 38 | public OpenConfigChannelHandler(String keyValue, OpenConfigLogicalChannelsHandler parent) { |
| 39 | modelObject = new DefaultChannel(); |
| 40 | modelObject.index(keyValue); |
| 41 | setResourceId(OPENCONFIG_NAME, NAME_SPACE, |
| 42 | new KeyLeaf(KEY_LEAF_NAME, NAME_SPACE, keyValue), |
| 43 | parent.getResourceIdBuilder()); |
| 44 | annotatedNodeInfos = parent.getAnnotatedNodeInfoList(); |
| 45 | |
| 46 | parent.addChannel(this); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Add Config to modelObject of target OPENCONFIG. |
| 51 | * |
| 52 | * @param config OpenConfigConfigOfChannelHandler having Config to be set for modelObject |
| 53 | * @return OpenConfigChannelHandler of target OPENCONFIG |
| 54 | */ |
| 55 | public OpenConfigChannelHandler addConfig(OpenConfigConfigOfChannelHandler config) { |
| 56 | modelObject.config(config.getModelObject()); |
| 57 | return this; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Add LogicalChannelAssignments to modelObject of target OPENCONFIG. |
| 62 | * |
| 63 | * @param logicalChannelAssignments OpenConfigLogicalChannelAssignmentsHandler having |
| 64 | * LogicalChannelAssignments to be set for modelObject |
| 65 | * @return OpenConfigChannelHandler of target OPENCONFIG |
| 66 | */ |
| 67 | public OpenConfigChannelHandler addLogicalChannelAssignments( |
| 68 | OpenConfigLogicalChannelAssignmentsHandler logicalChannelAssignments) { |
| 69 | modelObject.logicalChannelAssignments(logicalChannelAssignments.getModelObject()); |
| 70 | return this; |
| 71 | } |
| 72 | } |