Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +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 | 9f26ae5 | 2016-03-23 15:30:27 +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.utils; |
| 17 | |
| 18 | import org.onosproject.yangutils.datamodel.YangAugment; |
| 19 | import org.onosproject.yangutils.datamodel.YangCase; |
| 20 | import org.onosproject.yangutils.datamodel.YangChoice; |
| 21 | import org.onosproject.yangutils.datamodel.YangContainer; |
| 22 | import org.onosproject.yangutils.datamodel.YangGrouping; |
Vinod Kumar S | f677daf | 2016-04-15 18:08:57 +0530 | [diff] [blame] | 23 | import org.onosproject.yangutils.datamodel.YangLeaf; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 24 | import org.onosproject.yangutils.datamodel.YangList; |
| 25 | import org.onosproject.yangutils.datamodel.YangModule; |
| 26 | import org.onosproject.yangutils.datamodel.YangSubModule; |
| 27 | import org.onosproject.yangutils.datamodel.YangTypeDef; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 28 | import org.onosproject.yangutils.datamodel.YangUnion; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 29 | import org.onosproject.yangutils.datamodel.YangUses; |
Vidyashree Rama | 620b6e9 | 2016-03-28 11:59:27 +0530 | [diff] [blame] | 30 | import org.onosproject.yangutils.datamodel.YangNotification; |
Vidyashree Rama | 09e1ca5 | 2016-03-29 12:00:42 +0530 | [diff] [blame] | 31 | import org.onosproject.yangutils.datamodel.YangRpc; |
| 32 | import org.onosproject.yangutils.datamodel.YangInput; |
| 33 | import org.onosproject.yangutils.datamodel.YangOutput; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 34 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugment; |
| 35 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaCase; |
| 36 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaChoice; |
| 37 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaContainer; |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 38 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaEnumeration; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 39 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGrouping; |
Vinod Kumar S | f677daf | 2016-04-15 18:08:57 +0530 | [diff] [blame] | 40 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaLeaf; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 41 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaList; |
| 42 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; |
| 43 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; |
| 44 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDef; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 45 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUnion; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 46 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUses; |
Vidyashree Rama | 620b6e9 | 2016-03-28 11:59:27 +0530 | [diff] [blame] | 47 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaNotification; |
Vidyashree Rama | 09e1ca5 | 2016-03-29 12:00:42 +0530 | [diff] [blame] | 48 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaRpc; |
| 49 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaInput; |
| 50 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaOutput; |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 51 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 52 | |
| 53 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 54 | *Represents factory to create data model objects based on the target file type. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 55 | */ |
| 56 | public final class YangDataModelFactory { |
| 57 | |
| 58 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 59 | * Creates a YANG data model factory object. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 60 | */ |
| 61 | private YangDataModelFactory() { |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Based on the target language generate the inherited data model node. |
| 66 | * |
| 67 | * @param targetLanguage target language in which YANG mapping needs to be |
Vidyashree Rama | 620b6e9 | 2016-03-28 11:59:27 +0530 | [diff] [blame] | 68 | * generated |
| 69 | * @return the corresponding inherited node based on the target language |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 70 | */ |
| 71 | public static YangModule getYangModuleNode(GeneratedLanguage targetLanguage) { |
| 72 | switch (targetLanguage) { |
| 73 | case JAVA_GENERATION: { |
| 74 | return new YangJavaModule(); |
| 75 | } |
| 76 | default: { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 77 | throw new TranslatorException("Only YANG to Java is supported."); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 83 | * Returns based on the target language generate the inherited data model node. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 84 | * |
| 85 | * @param targetLanguage target language in which YANG mapping needs to be |
Vidyashree Rama | 620b6e9 | 2016-03-28 11:59:27 +0530 | [diff] [blame] | 86 | * generated |
| 87 | * @return the corresponding inherited node based on the target language |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 88 | */ |
| 89 | public static YangAugment getYangAugmentNode(GeneratedLanguage targetLanguage) { |
| 90 | switch (targetLanguage) { |
| 91 | case JAVA_GENERATION: { |
| 92 | return new YangJavaAugment(); |
| 93 | } |
| 94 | default: { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 95 | throw new TranslatorException("Only YANG to Java is supported."); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 101 | * Returns based on the target language generate the inherited data model node. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 102 | * |
| 103 | * @param targetLanguage target language in which YANG mapping needs to be |
Vidyashree Rama | 620b6e9 | 2016-03-28 11:59:27 +0530 | [diff] [blame] | 104 | * generated |
| 105 | * @return the corresponding inherited node based on the target language |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 106 | */ |
| 107 | public static YangCase getYangCaseNode(GeneratedLanguage targetLanguage) { |
| 108 | switch (targetLanguage) { |
| 109 | case JAVA_GENERATION: { |
| 110 | return new YangJavaCase(); |
| 111 | } |
| 112 | default: { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 113 | throw new TranslatorException("Only YANG to Java is supported."); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 119 | * Returns based on the target language generate the inherited data model node. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 120 | * |
| 121 | * @param targetLanguage target language in which YANG mapping needs to be |
Vidyashree Rama | 620b6e9 | 2016-03-28 11:59:27 +0530 | [diff] [blame] | 122 | * generated |
| 123 | * @return the corresponding inherited node based on the target language |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 124 | */ |
| 125 | public static YangChoice getYangChoiceNode(GeneratedLanguage targetLanguage) { |
| 126 | switch (targetLanguage) { |
| 127 | case JAVA_GENERATION: { |
| 128 | return new YangJavaChoice(); |
| 129 | } |
| 130 | default: { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 131 | throw new TranslatorException("Only YANG to Java is supported."); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 132 | } |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 137 | * Returns based on the target language generate the inherited data model node. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 138 | * |
| 139 | * @param targetLanguage target language in which YANG mapping needs to be |
Vidyashree Rama | 620b6e9 | 2016-03-28 11:59:27 +0530 | [diff] [blame] | 140 | * generated |
| 141 | * @return the corresponding inherited node based on the target language |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 142 | */ |
| 143 | public static YangContainer getYangContainerNode(GeneratedLanguage targetLanguage) { |
| 144 | switch (targetLanguage) { |
| 145 | case JAVA_GENERATION: { |
| 146 | return new YangJavaContainer(); |
| 147 | } |
| 148 | default: { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 149 | throw new TranslatorException("Only YANG to Java is supported."); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 150 | } |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 155 | * Returns based on the target language generate the inherited data model node. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 156 | * |
| 157 | * @param targetLanguage target language in which YANG mapping needs to be |
Vidyashree Rama | 620b6e9 | 2016-03-28 11:59:27 +0530 | [diff] [blame] | 158 | * generated |
| 159 | * @return the corresponding inherited node based on the target language |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 160 | */ |
| 161 | public static YangGrouping getYangGroupingNode(GeneratedLanguage targetLanguage) { |
| 162 | switch (targetLanguage) { |
| 163 | case JAVA_GENERATION: { |
| 164 | return new YangJavaGrouping(); |
| 165 | } |
| 166 | default: { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 167 | throw new TranslatorException("Only YANG to Java is supported."); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 168 | } |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 173 | * Returns based on the target language generate the inherited data model node. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 174 | * |
| 175 | * @param targetLanguage target language in which YANG mapping needs to be |
Vidyashree Rama | 620b6e9 | 2016-03-28 11:59:27 +0530 | [diff] [blame] | 176 | * generated |
| 177 | * @return the corresponding inherited node based on the target language |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 178 | */ |
| 179 | public static YangList getYangListNode(GeneratedLanguage targetLanguage) { |
| 180 | switch (targetLanguage) { |
| 181 | case JAVA_GENERATION: { |
| 182 | return new YangJavaList(); |
| 183 | } |
| 184 | default: { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 185 | throw new TranslatorException("Only YANG to Java is supported."); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 186 | } |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 191 | * Returns based on the target language generate the inherited data model node. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 192 | * |
| 193 | * @param targetLanguage target language in which YANG mapping needs to be |
Vidyashree Rama | 620b6e9 | 2016-03-28 11:59:27 +0530 | [diff] [blame] | 194 | * generated |
| 195 | * @return the corresponding inherited node based on the target language |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 196 | */ |
| 197 | public static YangSubModule getYangSubModuleNode(GeneratedLanguage targetLanguage) { |
| 198 | switch (targetLanguage) { |
| 199 | case JAVA_GENERATION: { |
| 200 | return new YangJavaSubModule(); |
| 201 | } |
| 202 | default: { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 203 | throw new TranslatorException("Only YANG to Java is supported."); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 204 | } |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 209 | * Returns based on the target language generate the inherited data model node. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 210 | * |
| 211 | * @param targetLanguage target language in which YANG mapping needs to be |
Vidyashree Rama | 620b6e9 | 2016-03-28 11:59:27 +0530 | [diff] [blame] | 212 | * generated |
| 213 | * @return the corresponding inherited node based on the target language |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 214 | */ |
| 215 | public static YangTypeDef getYangTypeDefNode(GeneratedLanguage targetLanguage) { |
| 216 | switch (targetLanguage) { |
| 217 | case JAVA_GENERATION: { |
| 218 | return new YangJavaTypeDef(); |
| 219 | } |
| 220 | default: { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 221 | throw new TranslatorException("Only YANG to Java is supported."); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 222 | } |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 227 | * Returns based on the target language generate the inherited data model node. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 228 | * |
| 229 | * @param targetLanguage target language in which YANG mapping needs to be |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 230 | * generated |
| 231 | * @return the corresponding inherited node based on the target language |
| 232 | */ |
| 233 | public static YangUnion getYangUnionNode(GeneratedLanguage targetLanguage) { |
| 234 | switch (targetLanguage) { |
| 235 | case JAVA_GENERATION: { |
| 236 | return new YangJavaUnion(); |
| 237 | } |
| 238 | default: { |
| 239 | throw new TranslatorException("Only YANG to Java is supported."); |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | /** |
| 245 | * Returns based on the target language generate the inherited data model node. |
| 246 | * |
| 247 | * @param targetLanguage target language in which YANG mapping needs to be |
| 248 | * generated |
Vidyashree Rama | 620b6e9 | 2016-03-28 11:59:27 +0530 | [diff] [blame] | 249 | * @return the corresponding inherited node based on the target language |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 250 | */ |
| 251 | public static YangUses getYangUsesNode(GeneratedLanguage targetLanguage) { |
| 252 | switch (targetLanguage) { |
| 253 | case JAVA_GENERATION: { |
| 254 | return new YangJavaUses(); |
| 255 | } |
| 256 | default: { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 257 | throw new TranslatorException("Only YANG to Java is supported."); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 258 | } |
| 259 | } |
| 260 | } |
Vidyashree Rama | 620b6e9 | 2016-03-28 11:59:27 +0530 | [diff] [blame] | 261 | |
| 262 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 263 | * Returns based on the target language generate the inherited data model node. |
Vidyashree Rama | 620b6e9 | 2016-03-28 11:59:27 +0530 | [diff] [blame] | 264 | * |
| 265 | * @param targetLanguage target language in which YANG mapping needs to be |
| 266 | * generated |
| 267 | * @return the corresponding inherited node based on the target language |
| 268 | */ |
| 269 | public static YangNotification getYangNotificationNode(GeneratedLanguage targetLanguage) { |
| 270 | switch (targetLanguage) { |
| 271 | case JAVA_GENERATION: { |
| 272 | return new YangJavaNotification(); |
| 273 | } |
| 274 | default: { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 275 | throw new TranslatorException("Only YANG to Java is supported."); |
Vidyashree Rama | 620b6e9 | 2016-03-28 11:59:27 +0530 | [diff] [blame] | 276 | } |
| 277 | } |
| 278 | } |
Vidyashree Rama | 09e1ca5 | 2016-03-29 12:00:42 +0530 | [diff] [blame] | 279 | |
| 280 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 281 | * Returns based on the target language generate the inherited data model node. |
Vidyashree Rama | 09e1ca5 | 2016-03-29 12:00:42 +0530 | [diff] [blame] | 282 | * |
| 283 | * @param targetLanguage target language in which YANG mapping needs to be |
| 284 | * generated |
| 285 | * @return the corresponding inherited node based on the target language |
| 286 | */ |
Vinod Kumar S | f677daf | 2016-04-15 18:08:57 +0530 | [diff] [blame] | 287 | public static YangLeaf getYangLeaf(GeneratedLanguage targetLanguage) { |
| 288 | switch (targetLanguage) { |
| 289 | case JAVA_GENERATION: { |
| 290 | return new YangJavaLeaf(); |
| 291 | } |
| 292 | default: { |
| 293 | throw new RuntimeException("Only YANG to Java is supported."); |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | /** |
| 298 | * Returns based on the target language generate the inherited data model node. |
| 299 | * |
| 300 | * @param targetLanguage target language in which YANG mapping needs to be |
| 301 | * generated |
| 302 | * @return the corresponding inherited node based on the target language |
| 303 | */ |
Vidyashree Rama | 09e1ca5 | 2016-03-29 12:00:42 +0530 | [diff] [blame] | 304 | public static YangRpc getYangRpcNode(GeneratedLanguage targetLanguage) { |
| 305 | switch (targetLanguage) { |
| 306 | case JAVA_GENERATION: { |
| 307 | return new YangJavaRpc(); |
| 308 | } |
| 309 | default: { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 310 | throw new TranslatorException("Only YANG to Java is supported."); |
Vidyashree Rama | 09e1ca5 | 2016-03-29 12:00:42 +0530 | [diff] [blame] | 311 | } |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 316 | * Returns based on the target language generate the inherited data model node. |
Vidyashree Rama | 09e1ca5 | 2016-03-29 12:00:42 +0530 | [diff] [blame] | 317 | * |
| 318 | * @param targetLanguage target language in which YANG mapping needs to be |
| 319 | * generated |
| 320 | * @return the corresponding inherited node based on the target language |
| 321 | */ |
| 322 | public static YangInput getYangInputNode(GeneratedLanguage targetLanguage) { |
| 323 | switch (targetLanguage) { |
| 324 | case JAVA_GENERATION: { |
| 325 | return new YangJavaInput(); |
| 326 | } |
| 327 | default: { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 328 | throw new TranslatorException("Only YANG to Java is supported."); |
Vidyashree Rama | 09e1ca5 | 2016-03-29 12:00:42 +0530 | [diff] [blame] | 329 | } |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 334 | * Returns based on the target language generate the inherited data model node. |
Vidyashree Rama | 09e1ca5 | 2016-03-29 12:00:42 +0530 | [diff] [blame] | 335 | * |
| 336 | * @param targetLanguage target language in which YANG mapping needs to be |
| 337 | * generated |
| 338 | * @return the corresponding inherited node based on the target language |
| 339 | */ |
| 340 | public static YangOutput getYangOutputNode(GeneratedLanguage targetLanguage) { |
| 341 | switch (targetLanguage) { |
| 342 | case JAVA_GENERATION: { |
| 343 | return new YangJavaOutput(); |
| 344 | } |
| 345 | default: { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 346 | throw new TranslatorException("Only YANG to Java is supported."); |
Vidyashree Rama | 09e1ca5 | 2016-03-29 12:00:42 +0530 | [diff] [blame] | 347 | } |
| 348 | } |
| 349 | } |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 350 | |
| 351 | /** |
| 352 | * Returns based on the target language generate the inherited data model node. |
| 353 | * |
| 354 | * @param targetLanguage target language in which YANG mapping needs to be |
| 355 | * generated |
| 356 | * @return the corresponding inherited node based on the target language |
| 357 | */ |
| 358 | public static YangJavaEnumeration getYangEnumerationNode(GeneratedLanguage targetLanguage) { |
| 359 | switch (targetLanguage) { |
| 360 | case JAVA_GENERATION: { |
| 361 | return new YangJavaEnumeration(); |
| 362 | } |
| 363 | default: { |
| 364 | throw new TranslatorException("Only YANG to Java is supported."); |
| 365 | } |
| 366 | } |
| 367 | } |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 368 | } |