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.terminallogicalchanassignmentconfig.AssignmentTypeEnum; |
| 19 | import org.onosproject.yang.gen.v1.openconfigterminaldevice.rev20161222.openconfigterminaldevice.terminallogicalchanassignmenttop.logicalchannelassignments.assignment.DefaultConfig; |
| 20 | |
| 21 | import java.math.BigDecimal; |
| 22 | |
| 23 | /** |
| 24 | * Utility class to deal with OPENCONFIG Assignment/Config ModelObject & Annotation. |
| 25 | */ |
| 26 | public final class OpenConfigConfigOfAssignmentHandler |
| 27 | extends OpenConfigObjectHandler<DefaultConfig> { |
| 28 | |
| 29 | private static final String OPENCONFIG_NAME = "config"; |
| 30 | private static final String NAME_SPACE = "http://openconfig.net/yang/terminal-device"; |
| 31 | |
| 32 | /** |
| 33 | * OpenConfigConfigOfAssignmentHandler Constructor. |
| 34 | * |
| 35 | * @param parent OpenConfigAssignmentHandler of parent OPENCONFIG(assignment) |
| 36 | */ |
| 37 | public OpenConfigConfigOfAssignmentHandler(OpenConfigAssignmentHandler parent) { |
| 38 | modelObject = new DefaultConfig(); |
| 39 | setResourceId(OPENCONFIG_NAME, NAME_SPACE, null, parent.getResourceIdBuilder()); |
| 40 | annotatedNodeInfos = parent.getAnnotatedNodeInfoList(); |
| 41 | |
| 42 | parent.addConfig(this); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Add child OPENCONFIG(assignment-type). |
| 47 | * |
| 48 | * @param assignmentType AssignmentTypeEnum to be set for modelObject |
| 49 | * @return OpenConfigConfigOfAssignmentHandler of target OPENCONFIG |
| 50 | */ |
| 51 | public OpenConfigConfigOfAssignmentHandler addAssignmentType( |
| 52 | AssignmentTypeEnum assignmentType) { |
| 53 | modelObject.assignmentType(assignmentType); |
| 54 | return this; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Add child OPENCONFIG(logical-channel). |
| 59 | * |
| 60 | * @param logicalChannel String to be set for modelObject |
| 61 | * @return OpenConfigConfigOfAssignmentHandler of target OPENCONFIG |
| 62 | */ |
| 63 | public OpenConfigConfigOfAssignmentHandler addLogicalChannel(String logicalChannel) { |
| 64 | modelObject.logicalChannel(logicalChannel); |
| 65 | return this; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Add child OPENCONFIG(allocation). |
| 70 | * |
| 71 | * @param allocation BigDecimal to be set for modelObject |
| 72 | * @return OpenConfigConfigOfAssignmentHandler of target OPENCONFIG |
| 73 | */ |
| 74 | public OpenConfigConfigOfAssignmentHandler addAllocation(BigDecimal allocation) { |
| 75 | modelObject.allocation(allocation); |
| 76 | return this; |
| 77 | } |
| 78 | } |