Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 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 | |
| 17 | package org.onosproject.yangutils.translator.tojava; |
| 18 | |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 19 | import java.io.File; |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 20 | import java.io.IOException; |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 21 | import java.util.ArrayList; |
| 22 | import java.util.List; |
| 23 | |
| 24 | import org.onosproject.yangutils.datamodel.YangNode; |
| 25 | import org.onosproject.yangutils.datamodel.YangType; |
| 26 | import org.onosproject.yangutils.datamodel.YangTypeHolder; |
| 27 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
| 28 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaType; |
Bharat saraswal | 33dfa01 | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 29 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 30 | |
Bharat saraswal | ab4c6ba | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 31 | import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED; |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 32 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; |
| 33 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; |
| 34 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK; |
| 35 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_IMPL_MASK; |
| 36 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.OF_STRING_IMPL_MASK; |
| 37 | import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 38 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateTypeDefClassFile; |
| 39 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateUnionClassFile; |
Bharat saraswal | c0e0484 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 40 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 41 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOfMethodStringAndJavaDoc; |
| 42 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getTypeConstructorStringAndJavaDoc; |
| 43 | import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.closeFile; |
| 44 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
| 45 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
| 46 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage; |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 47 | |
| 48 | /** |
| 49 | * Represents implementation of java data type code fragments temporary implementations. |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 50 | * Maintains the temp files required specific for user defined data type java snippet generation. |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 51 | */ |
| 52 | public class TempJavaTypeFragmentFiles |
| 53 | extends TempJavaFragmentFiles { |
| 54 | |
| 55 | /** |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 56 | * File name for of string method. |
| 57 | */ |
| 58 | private static final String OF_STRING_METHOD_FILE_NAME = "OfString"; |
| 59 | |
| 60 | /** |
| 61 | * File name for construction for special type like union, typedef. |
| 62 | */ |
| 63 | private static final String CONSTRUCTOR_FOR_TYPE_FILE_NAME = "ConstructorForType"; |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 64 | |
| 65 | /** |
| 66 | * File name for typedef class file name suffix. |
| 67 | */ |
| 68 | private static final String TYPEDEF_CLASS_FILE_NAME_SUFFIX = EMPTY_STRING; |
| 69 | |
| 70 | /** |
| 71 | * File name for generated class file for special type like union, typedef |
| 72 | * suffix. |
| 73 | */ |
| 74 | private static final String UNION_TYPE_CLASS_FILE_NAME_SUFFIX = EMPTY_STRING; |
| 75 | |
| 76 | /** |
| 77 | * Temporary file handle for of string method of class. |
| 78 | */ |
| 79 | private File ofStringImplTempFileHandle; |
| 80 | /** |
| 81 | * Temporary file handle for constructor for type class. |
| 82 | */ |
| 83 | private File constructorForTypeTempFileHandle; |
| 84 | |
| 85 | /** |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 86 | * Java file handle for typedef class file. |
| 87 | */ |
| 88 | private File typedefClassJavaFileHandle; |
| 89 | /** |
| 90 | * Java file handle for type class like union, typedef file. |
| 91 | */ |
| 92 | private File typeClassJavaFileHandle; |
| 93 | |
| 94 | /** |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 95 | * Creates an instance of temporary java code fragment. |
| 96 | * |
| 97 | * @param javaFileInfo generated java file info |
| 98 | * @throws IOException when fails to create new file handle |
| 99 | */ |
| 100 | public TempJavaTypeFragmentFiles(JavaFileInfo javaFileInfo) |
| 101 | throws IOException { |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 102 | |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 103 | super(javaFileInfo); |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 104 | |
| 105 | /* |
| 106 | * Initialize getterImpl, attributes, hash code, equals and to strings |
| 107 | * when generation file type matches to typeDef class mask. |
| 108 | */ |
| 109 | addGeneratedTempFile(OF_STRING_IMPL_MASK); |
| 110 | addGeneratedTempFile(CONSTRUCTOR_FOR_TYPE_MASK); |
| 111 | addGeneratedTempFile(FROM_STRING_IMPL_MASK); |
| 112 | |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 113 | setOfStringImplTempFileHandle(getTemporaryFileHandle(OF_STRING_METHOD_FILE_NAME)); |
| 114 | setConstructorForTypeTempFileHandle(getTemporaryFileHandle(CONSTRUCTOR_FOR_TYPE_FILE_NAME)); |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 115 | |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 116 | } |
| 117 | |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 118 | /** |
| 119 | * Returns type class constructor method's temporary file handle. |
| 120 | * |
| 121 | * @return type class constructor method's temporary file handle |
| 122 | */ |
| 123 | |
| 124 | public File getConstructorForTypeTempFileHandle() { |
| 125 | return constructorForTypeTempFileHandle; |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Sets type class constructor method's temporary file handle. |
| 130 | * |
| 131 | * @param constructorForTypeTempFileHandle type class constructor method's |
| 132 | * temporary file handle |
| 133 | */ |
| 134 | private void setConstructorForTypeTempFileHandle(File constructorForTypeTempFileHandle) { |
| 135 | this.constructorForTypeTempFileHandle = constructorForTypeTempFileHandle; |
| 136 | } |
| 137 | |
| 138 | /** |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 139 | * Returns java file handle for typedef class file. |
| 140 | * |
| 141 | * @return java file handle for typedef class file |
| 142 | */ |
| 143 | File getTypedefClassJavaFileHandle() { |
| 144 | return typedefClassJavaFileHandle; |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * Sets the java file handle for typedef class file. |
| 149 | * |
| 150 | * @param typedefClassJavaFileHandle java file handle |
| 151 | */ |
| 152 | private void setTypedefClassJavaFileHandle(File typedefClassJavaFileHandle) { |
| 153 | this.typedefClassJavaFileHandle = typedefClassJavaFileHandle; |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * Returns java file handle for type class file. |
| 158 | * |
| 159 | * @return java file handle for type class file |
| 160 | */ |
| 161 | File getTypeClassJavaFileHandle() { |
| 162 | return typeClassJavaFileHandle; |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * Sets the java file handle for type class file. |
| 167 | * |
| 168 | * @param typeClassJavaFileHandle type file handle |
| 169 | */ |
| 170 | private void setTypeClassJavaFileHandle(File typeClassJavaFileHandle) { |
| 171 | this.typeClassJavaFileHandle = typeClassJavaFileHandle; |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Returns of string method's temporary file handle. |
| 176 | * |
| 177 | * @return of string method's temporary file handle |
| 178 | */ |
| 179 | |
| 180 | public File getOfStringImplTempFileHandle() { |
| 181 | return ofStringImplTempFileHandle; |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * Set of string method's temporary file handle. |
| 186 | * |
| 187 | * @param ofStringImplTempFileHandle of string method's temporary file |
| 188 | * handle |
| 189 | */ |
| 190 | private void setOfStringImplTempFileHandle(File ofStringImplTempFileHandle) { |
| 191 | this.ofStringImplTempFileHandle = ofStringImplTempFileHandle; |
| 192 | } |
| 193 | |
| 194 | /** |
| 195 | * Adds all the type in the current data model node as part of the generated |
| 196 | * temporary file. |
| 197 | * |
| 198 | * @param yangTypeHolder YANG java data model node which has type info, eg union / |
| 199 | * typedef |
Bharat saraswal | 33dfa01 | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 200 | * @param pluginConfig plugin configurations for naming conventions |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 201 | * @throws IOException IO operation fail |
| 202 | */ |
Bharat saraswal | 33dfa01 | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 203 | public void addTypeInfoToTempFiles(YangTypeHolder yangTypeHolder, YangPluginConfig pluginConfig) |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 204 | throws IOException { |
| 205 | |
| 206 | List<YangType<?>> typeList = yangTypeHolder.getTypeList(); |
| 207 | if (typeList != null) { |
| 208 | for (YangType<?> yangType : typeList) { |
| 209 | if (!(yangType instanceof YangJavaType)) { |
| 210 | throw new TranslatorException("Type does not have Java info"); |
| 211 | } |
| 212 | YangJavaType<?> javaType = (YangJavaType<?>) yangType; |
Bharat saraswal | 33dfa01 | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 213 | javaType.updateJavaQualifiedInfo(pluginConfig.getConflictResolver()); |
Bharat saraswal | c0e0484 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 214 | String typeName = javaType.getDataTypeName(); |
| 215 | |
Bharat saraswal | ab4c6ba | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 216 | if (javaType.getDataType().equals(DERIVED)) { |
Bharat saraswal | 33dfa01 | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 217 | typeName = getCamelCase(typeName, pluginConfig.getConflictResolver()); |
Bharat saraswal | c0e0484 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 218 | } |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 219 | JavaAttributeInfo javaAttributeInfo = getAttributeInfoForTheData( |
| 220 | javaType.getJavaQualifiedInfo(), |
Bharat saraswal | c0e0484 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 221 | typeName, javaType, |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 222 | getIsQualifiedAccessOrAddToImportList(javaType.getJavaQualifiedInfo()), |
| 223 | false); |
Bharat saraswal | 33dfa01 | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 224 | addJavaSnippetInfoToApplicableTempFiles((YangNode) yangTypeHolder, javaAttributeInfo, |
| 225 | pluginConfig); |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 226 | } |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | /** |
| 231 | * Adds the new attribute info to the target generated temporary files for |
| 232 | * union class. |
| 233 | * |
| 234 | * @param hasType the node for which the type is being added as an attribute |
| 235 | * @param javaAttributeInfo the attribute info that needs to be added to |
| 236 | * temporary files |
Bharat saraswal | 33dfa01 | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 237 | * @param pluginConfig plugin configurations |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 238 | * @throws IOException IO operation fail |
| 239 | */ |
Bharat saraswal | 33dfa01 | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 240 | private void addJavaSnippetInfoToApplicableTempFiles(YangNode hasType, JavaAttributeInfo javaAttributeInfo, |
| 241 | YangPluginConfig pluginConfig) |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 242 | throws IOException { |
| 243 | |
Bharat saraswal | 33dfa01 | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 244 | super.addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo, pluginConfig); |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 245 | |
| 246 | if ((getGeneratedTempFiles() & OF_STRING_IMPL_MASK) != 0) { |
Bharat saraswal | 33dfa01 | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 247 | addOfStringMethod(javaAttributeInfo, pluginConfig); |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 248 | } |
| 249 | if ((getGeneratedTempFiles() & CONSTRUCTOR_FOR_TYPE_MASK) != 0) { |
Bharat saraswal | 33dfa01 | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 250 | addTypeConstructor(javaAttributeInfo, pluginConfig); |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 251 | } |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | /** |
| 255 | * Adds type constructor. |
| 256 | * |
| 257 | * @param attr attribute info |
Bharat saraswal | 33dfa01 | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 258 | * @param pluginConfig plugin configurations |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 259 | * @throws IOException when fails to append to temporary file |
| 260 | */ |
Bharat saraswal | 33dfa01 | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 261 | private void addTypeConstructor(JavaAttributeInfo attr, YangPluginConfig pluginConfig) |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 262 | throws IOException { |
| 263 | appendToFile(getConstructorForTypeTempFileHandle(), getTypeConstructorStringAndJavaDoc(attr, |
Bharat saraswal | 33dfa01 | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 264 | getGeneratedJavaClassName(), pluginConfig) + NEW_LINE); |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | /** |
| 268 | * Adds of string for type. |
| 269 | * |
| 270 | * @param attr attribute info |
Bharat saraswal | 33dfa01 | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 271 | * @param pluginConfig plugin configurations |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 272 | * @throws IOException when fails to append to temporary file |
| 273 | */ |
Bharat saraswal | 33dfa01 | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 274 | private void addOfStringMethod(JavaAttributeInfo attr, YangPluginConfig pluginConfig) |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 275 | throws IOException { |
| 276 | appendToFile(getOfStringImplTempFileHandle(), getOfMethodStringAndJavaDoc(attr, |
Bharat saraswal | 33dfa01 | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 277 | getGeneratedJavaClassName(), pluginConfig) |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 278 | + NEW_LINE); |
| 279 | } |
| 280 | |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 281 | /** |
| 282 | * Removes all temporary file handles. |
| 283 | * |
| 284 | * @param isErrorOccurred when translator fails to generate java files we |
| 285 | * need to close all open file handles include temporary files |
| 286 | * and java files. |
| 287 | * @throws IOException when failed to delete the temporary files |
| 288 | */ |
Bharat saraswal | c0e0484 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 289 | @Override |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 290 | public void freeTemporaryResources(boolean isErrorOccurred) |
| 291 | throws IOException { |
| 292 | boolean isError = isErrorOccurred; |
| 293 | |
| 294 | if ((getGeneratedJavaFiles() & GENERATE_TYPEDEF_CLASS) != 0) { |
| 295 | closeFile(getTypedefClassJavaFileHandle(), isError); |
| 296 | } |
| 297 | |
| 298 | if ((getGeneratedJavaFiles() & GENERATE_UNION_CLASS) != 0) { |
| 299 | closeFile(getTypeClassJavaFileHandle(), isError); |
| 300 | } |
| 301 | |
| 302 | if ((getGeneratedTempFiles() & CONSTRUCTOR_FOR_TYPE_MASK) != 0) { |
| 303 | closeFile(getConstructorForTypeTempFileHandle(), true); |
| 304 | } |
| 305 | if ((getGeneratedTempFiles() & OF_STRING_IMPL_MASK) != 0) { |
| 306 | closeFile(getOfStringImplTempFileHandle(), true); |
| 307 | } |
| 308 | if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) { |
| 309 | closeFile(getFromStringImplTempFileHandle(), true); |
| 310 | } |
| 311 | |
| 312 | super.freeTemporaryResources(isErrorOccurred); |
Bharat saraswal | c0e0484 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 313 | |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | /** |
| 317 | * Constructs java code exit. |
| 318 | * |
| 319 | * @param fileType generated file type |
| 320 | * @param curNode current YANG node |
| 321 | * @throws IOException when fails to generate java files |
| 322 | */ |
Bharat saraswal | c0e0484 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 323 | @Override |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 324 | public void generateJavaFile(int fileType, YangNode curNode) |
| 325 | throws IOException { |
| 326 | List<String> imports = new ArrayList<>(); |
| 327 | if (isAttributePresent()) { |
| 328 | imports = getJavaImportData().getImports(); |
| 329 | } |
| 330 | |
| 331 | createPackage(curNode); |
| 332 | |
| 333 | /* |
| 334 | * Creates type def class file. |
| 335 | */ |
| 336 | if ((fileType & GENERATE_TYPEDEF_CLASS) != 0) { |
| 337 | addImportsToStringAndHasCodeMethods(curNode, imports); |
| 338 | setTypedefClassJavaFileHandle(getJavaFileHandle(getJavaClassName(TYPEDEF_CLASS_FILE_NAME_SUFFIX))); |
| 339 | generateTypeDefClassFile(getTypedefClassJavaFileHandle(), curNode, imports); |
| 340 | } |
| 341 | /* |
| 342 | * Creates type class file. |
| 343 | */ |
| 344 | if ((fileType & GENERATE_UNION_CLASS) != 0) { |
| 345 | addImportsToStringAndHasCodeMethods(curNode, imports); |
| 346 | setTypeClassJavaFileHandle(getJavaFileHandle(getJavaClassName(UNION_TYPE_CLASS_FILE_NAME_SUFFIX))); |
| 347 | generateUnionClassFile(getTypeClassJavaFileHandle(), curNode, imports); |
| 348 | } |
| 349 | |
| 350 | /* |
| 351 | * Close all the file handles. |
| 352 | */ |
| 353 | freeTemporaryResources(false); |
| 354 | } |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 355 | } |