Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 0f7908b | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [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.yangutils.datamodel; |
| 17 | |
| 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 19 | import org.onosproject.yangutils.parser.Parsable; |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 20 | import org.onosproject.yangutils.utils.YangConstructType; |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 21 | |
| 22 | /*- |
| 23 | * Reference 6020. |
| 24 | * |
| 25 | * The "belongs-to" statement specifies the module to which the |
| 26 | * submodule belongs. The argument is an identifier that is the name of |
| 27 | * the module. |
| 28 | * |
| 29 | * A submodule MUST only be included by the module to which it belongs, |
| 30 | * or by another submodule that belongs to that module. |
| 31 | * |
| 32 | * The mandatory "prefix" sub-statement assigns a prefix for the module |
| 33 | * to which the submodule belongs. All definitions in the local |
| 34 | * submodule and any included submodules can be accessed by using the |
| 35 | * prefix. |
| 36 | * |
| 37 | * The belongs-to's sub-statements |
| 38 | * |
| 39 | * +--------------+---------+-------------+ |
| 40 | * | substatement | section | cardinality | |
| 41 | * +--------------+---------+-------------+ |
| 42 | * | prefix | 7.1.4 | 1 | |
| 43 | * +--------------+---------+-------------+ |
| 44 | */ |
| 45 | |
| 46 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 47 | * Represents the belongs-to data type information. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 48 | */ |
| 49 | public class YangBelongsTo implements Parsable { |
| 50 | |
| 51 | /** |
| 52 | * Reference RFC 6020. |
| 53 | * |
| 54 | * The "belongs-to" statement specifies the module to which the submodule |
| 55 | * belongs. The argument is an identifier that is the name of the module. |
| 56 | */ |
| 57 | private String belongsToModuleName; |
| 58 | |
| 59 | /** |
Vidyashree Rama | b624817 | 2016-05-17 16:16:15 +0530 | [diff] [blame^] | 60 | * Module node to which sub-module belongs to. |
| 61 | */ |
| 62 | private YangNode moduleNode; |
| 63 | |
| 64 | /** |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 65 | * Reference RFC 6020. |
| 66 | * |
| 67 | * The mandatory "prefix" substatement assigns a prefix for the module to |
| 68 | * which the submodule belongs. All definitions in the local submodule and |
| 69 | * any included submodules can be accessed by using the prefix. |
| 70 | */ |
| 71 | private String prefix; |
| 72 | |
| 73 | /** |
| 74 | * Create a belongs to object. |
| 75 | */ |
| 76 | public YangBelongsTo() { |
| 77 | |
| 78 | } |
| 79 | |
| 80 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 81 | * Returns the belongs to module name. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 82 | * |
| 83 | * @return the belongs to module name |
| 84 | */ |
| 85 | public String getBelongsToModuleName() { |
| 86 | return belongsToModuleName; |
| 87 | } |
| 88 | |
| 89 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 90 | * Sets the belongs to module name. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 91 | * |
| 92 | * @param belongsToModuleName the belongs to module name to set |
| 93 | * |
| 94 | */ |
| 95 | public void setBelongsToModuleName(String belongsToModuleName) { |
| 96 | this.belongsToModuleName = belongsToModuleName; |
| 97 | } |
| 98 | |
| 99 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 100 | * Returns the prefix. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 101 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 102 | * @return the prefix |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 103 | */ |
| 104 | public String getPrefix() { |
| 105 | return prefix; |
| 106 | } |
| 107 | |
| 108 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 109 | * Sets the prefix. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 110 | * |
| 111 | * @param prefix the prefix to set |
| 112 | */ |
| 113 | public void setPrefix(String prefix) { |
| 114 | this.prefix = prefix; |
| 115 | } |
| 116 | |
| 117 | /** |
Vidyashree Rama | b624817 | 2016-05-17 16:16:15 +0530 | [diff] [blame^] | 118 | * Returns the module data model node. |
| 119 | * |
| 120 | * @return the module data model node |
| 121 | */ |
| 122 | public YangNode getModuleNode() { |
| 123 | return moduleNode; |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * Sets the module node. |
| 128 | * |
| 129 | * @param moduleNode module data model node |
| 130 | */ |
| 131 | public void setModuleNode(YangNode moduleNode) { |
| 132 | this.moduleNode = moduleNode; |
| 133 | } |
| 134 | |
| 135 | /** |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 136 | * Returns the type of the data as belongs-to. |
| 137 | * |
| 138 | * @return ParsedDataType returns BELONGS_TO_DATA |
| 139 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 140 | @Override |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 141 | public YangConstructType getYangConstructType() { |
| 142 | return YangConstructType.BELONGS_TO_DATA; |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 146 | * Validates the data on entering the corresponding parse tree node. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 147 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 148 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 149 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 150 | @Override |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 151 | public void validateDataOnEntry() throws DataModelException { |
| 152 | // TODO auto-generated method stub, to be implemented by parser |
| 153 | } |
| 154 | |
| 155 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 156 | * Validates the data on exiting the corresponding parse tree node. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 157 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 158 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 159 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 160 | @Override |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 161 | public void validateDataOnExit() throws DataModelException { |
| 162 | // TODO auto-generated method stub, to be implemented by parser |
| 163 | } |
| 164 | } |