Vinod Kumar S | 79a374b | 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 | package org.onosproject.yangutils.translator.tojava; |
| 17 | |
| 18 | import java.io.File; |
| 19 | import java.io.IOException; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 20 | import java.util.List; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 21 | |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 22 | import org.onosproject.yangutils.datamodel.YangAugment; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 23 | import org.onosproject.yangutils.datamodel.YangAugmentableNode; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 24 | import org.onosproject.yangutils.datamodel.YangCase; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 25 | import org.onosproject.yangutils.datamodel.YangLeaf; |
| 26 | import org.onosproject.yangutils.datamodel.YangLeafList; |
| 27 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 28 | import org.onosproject.yangutils.datamodel.YangModule; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 29 | import org.onosproject.yangutils.datamodel.YangNode; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 30 | import org.onosproject.yangutils.datamodel.YangSubModule; |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 31 | import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo; |
| 32 | import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 33 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
| 34 | import org.onosproject.yangutils.translator.tojava.javamodel.JavaLeafInfoContainer; |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 35 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGroupingTranslator; |
| 36 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModuleTranslator; |
| 37 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModuleTranslator; |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 38 | import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 39 | |
Bharat saraswal | c2d3be1 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 40 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 41 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; |
| 42 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK; |
| 43 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 44 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 45 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; |
| 46 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPE_CLASS; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 47 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK; |
| 48 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 49 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.OPERATION_BUILDER_CLASS_MASK; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 50 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 51 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EQUALS_IMPL_MASK; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 52 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_IMPL_MASK; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 53 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK; |
| 54 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_INTERFACE_MASK; |
| 55 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.HASH_CODE_IMPL_MASK; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 56 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK; |
| 57 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK; |
| 58 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK; |
| 59 | import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 60 | import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedInfoOfFromString; |
| 61 | import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedTypeInfoOfCurNode; |
Gaurav Agrawal | bfce934 | 2016-06-15 13:58:01 +0530 | [diff] [blame] | 62 | import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.updateJavaFileInfo; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 63 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaAttributeDefination; |
| 64 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 65 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.sortImports; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 66 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderClassFile; |
| 67 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderInterfaceFile; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 68 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateImplClassFile; |
| 69 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateInterfaceFile; |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 70 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateOpParamBuilderClassFile; |
| 71 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateOpParamImplClassFile; |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 72 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.addResolvedAugmentedDataNodeImports; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 73 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 74 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 75 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildString; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 76 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getDefaultConstructorString; |
| 77 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethod; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 78 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getFromStringMethod; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 79 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass; |
| 80 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterString; |
| 81 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethod; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 82 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOverRideString; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 83 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass; |
| 84 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterString; |
| 85 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethod; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 86 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.parseBuilderInterfaceBuildMethodString; |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 87 | import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 88 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 89 | import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT; |
| 90 | import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE; |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 91 | import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 92 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
| 93 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 94 | import static org.onosproject.yangutils.utils.UtilConstants.IMPORT; |
| 95 | import static org.onosproject.yangutils.utils.UtilConstants.INTERFACE; |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 96 | import static org.onosproject.yangutils.utils.UtilConstants.MANAGER; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 97 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 98 | import static org.onosproject.yangutils.utils.UtilConstants.OPERATION; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 99 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 100 | import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE; |
| 101 | import static org.onosproject.yangutils.utils.UtilConstants.PROTECTED; |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 102 | import static org.onosproject.yangutils.utils.UtilConstants.REFERENCE; |
| 103 | import static org.onosproject.yangutils.utils.UtilConstants.REFERENCE_CARDINALITY; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 104 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 105 | import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 106 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; |
Vidyashree Rama | 72719fa | 2016-07-15 14:06:56 +0530 | [diff] [blame] | 107 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 108 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 109 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile; |
| 110 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 111 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 112 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath; |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 113 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; |
| 114 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
| 115 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 116 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile; |
| 117 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.mergeJavaFiles; |
Bharat saraswal | c2d3be1 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 118 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.validateLineLength; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 119 | |
| 120 | /** |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 121 | * Represents implementation of java code fragments temporary implementations. Manages the common temp file required for |
| 122 | * Java file(s) generated. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 123 | */ |
| 124 | public class TempJavaFragmentFiles { |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 125 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 126 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 127 | * File type extension for java classes. |
| 128 | */ |
| 129 | private static final String JAVA_FILE_EXTENSION = ".java"; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 130 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 131 | /** |
| 132 | * File type extension for temporary classes. |
| 133 | */ |
| 134 | private static final String TEMP_FILE_EXTENSION = ".tmp"; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 135 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 136 | /** |
| 137 | * Folder suffix for temporary files folder. |
| 138 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 139 | private static final String TEMP_FOLDER_NAME_SUFFIX = "-Temp"; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 140 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 141 | /** |
| 142 | * File name for getter method. |
| 143 | */ |
| 144 | private static final String GETTER_METHOD_FILE_NAME = "GetterMethod"; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 145 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 146 | /** |
| 147 | * File name for setter method. |
| 148 | */ |
| 149 | private static final String SETTER_METHOD_FILE_NAME = "SetterMethod"; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 150 | |
| 151 | /** |
| 152 | * File name for getter method implementation. |
| 153 | */ |
| 154 | private static final String GETTER_METHOD_IMPL_FILE_NAME = "GetterMethodImpl"; |
| 155 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 156 | /** |
| 157 | * File name for setter method implementation. |
| 158 | */ |
| 159 | private static final String SETTER_METHOD_IMPL_FILE_NAME = "SetterMethodImpl"; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 160 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 161 | /** |
| 162 | * File name for attributes. |
| 163 | */ |
| 164 | private static final String ATTRIBUTE_FILE_NAME = "Attributes"; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 165 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 166 | /** |
| 167 | * File name for to string method. |
| 168 | */ |
| 169 | private static final String TO_STRING_METHOD_FILE_NAME = "ToString"; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 170 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 171 | /** |
| 172 | * File name for hash code method. |
| 173 | */ |
| 174 | private static final String HASH_CODE_METHOD_FILE_NAME = "HashCode"; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 175 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 176 | /** |
| 177 | * File name for equals method. |
| 178 | */ |
| 179 | private static final String EQUALS_METHOD_FILE_NAME = "Equals"; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 180 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 181 | /** |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 182 | * File name for from string method. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 183 | */ |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 184 | private static final String FROM_STRING_METHOD_FILE_NAME = "FromString"; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 185 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 186 | /** |
| 187 | * File name for interface java file name suffix. |
| 188 | */ |
| 189 | private static final String INTERFACE_FILE_NAME_SUFFIX = EMPTY_STRING; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 190 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 191 | /** |
| 192 | * File name for builder interface file name suffix. |
| 193 | */ |
| 194 | private static final String BUILDER_INTERFACE_FILE_NAME_SUFFIX = BUILDER + INTERFACE; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 195 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 196 | /** |
| 197 | * File name for builder class file name suffix. |
| 198 | */ |
| 199 | private static final String BUILDER_CLASS_FILE_NAME_SUFFIX = BUILDER; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 200 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 201 | /** |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 202 | * Information about the java files being generated. |
| 203 | */ |
| 204 | private JavaFileInfo javaFileInfo; |
| 205 | |
| 206 | /** |
| 207 | * Imported class info. |
| 208 | */ |
| 209 | private JavaImportData javaImportData; |
| 210 | |
| 211 | /** |
| 212 | * The variable which guides the types of temporary files generated using the temporary generated file types mask. |
| 213 | */ |
| 214 | private int generatedTempFiles; |
| 215 | |
| 216 | /** |
| 217 | * Absolute path where the target java file needs to be generated. |
| 218 | */ |
| 219 | private String absoluteDirPath; |
| 220 | |
| 221 | /** |
| 222 | * Contains all the interface(s)/class name which will be extended by generated files. |
| 223 | */ |
| 224 | private JavaExtendsListHolder javaExtendsListHolder; |
| 225 | |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 226 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 227 | * Java file handle for interface file. |
| 228 | */ |
| 229 | private File interfaceJavaFileHandle; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 230 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 231 | /** |
| 232 | * Java file handle for builder interface file. |
| 233 | */ |
| 234 | private File builderInterfaceJavaFileHandle; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 235 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 236 | /** |
| 237 | * Java file handle for builder class file. |
| 238 | */ |
| 239 | private File builderClassJavaFileHandle; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 240 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 241 | /** |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 242 | * Java file handle for builder op param class file. |
| 243 | */ |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 244 | private File builderOpParamClassJavaFileHandle; |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 245 | |
| 246 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 247 | * Java file handle for impl class file. |
| 248 | */ |
| 249 | private File implClassJavaFileHandle; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 250 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 251 | /** |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 252 | * Java file handle for op param class file. |
| 253 | */ |
| 254 | private File opParamClassJavaFileHandle; |
| 255 | |
| 256 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 257 | * Temporary file handle for attribute. |
| 258 | */ |
| 259 | private File attributesTempFileHandle; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 260 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 261 | /** |
| 262 | * Temporary file handle for getter of interface. |
| 263 | */ |
| 264 | private File getterInterfaceTempFileHandle; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 265 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 266 | /** |
| 267 | * Temporary file handle for setter of interface. |
| 268 | */ |
| 269 | private File setterInterfaceTempFileHandle; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 270 | |
| 271 | /** |
| 272 | * Temporary file handle for getter of class. |
| 273 | */ |
| 274 | private File getterImplTempFileHandle; |
| 275 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 276 | /** |
| 277 | * Temporary file handle for setter of class. |
| 278 | */ |
| 279 | private File setterImplTempFileHandle; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 280 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 281 | /** |
| 282 | * Temporary file handle for hash code method of class. |
| 283 | */ |
| 284 | private File hashCodeImplTempFileHandle; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 285 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 286 | /** |
| 287 | * Temporary file handle for equals method of class. |
| 288 | */ |
| 289 | private File equalsImplTempFileHandle; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 290 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 291 | /** |
| 292 | * Temporary file handle for to string method of class. |
| 293 | */ |
| 294 | private File toStringImplTempFileHandle; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 295 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 296 | /** |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 297 | * Temporary file handle for from string method of class. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 298 | */ |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 299 | private File fromStringImplTempFileHandle; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 300 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 301 | /** |
| 302 | * Import info for case. |
| 303 | */ |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 304 | private JavaQualifiedTypeInfoTranslator caseImportInfo; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 305 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 306 | /** |
| 307 | * Is attribute added. |
| 308 | */ |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 309 | private boolean isAttributePresent; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 310 | |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 311 | /** |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 312 | * Base code gen path. |
| 313 | */ |
| 314 | private String baseCodePath; |
| 315 | |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 316 | TempJavaFragmentFiles() { |
| 317 | } |
| 318 | |
| 319 | /** |
| 320 | * Creates an instance of temporary java code fragment. |
| 321 | * |
| 322 | * @param javaFileInfo generated java file information |
| 323 | * @throws IOException when fails to create new file handle |
| 324 | */ |
| 325 | TempJavaFragmentFiles(JavaFileInfo javaFileInfo) |
| 326 | throws IOException { |
| 327 | setJavaExtendsListHolder(new JavaExtendsListHolder()); |
| 328 | setJavaImportData(new JavaImportData()); |
| 329 | setJavaFileInfo(javaFileInfo); |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 330 | if ((javaFileInfo.getGeneratedFileTypes() & GENERATE_SERVICE_AND_MANAGER) != 0) { |
| 331 | setBaseCodePath(getJavaFileInfo().getPluginConfig().getCodeGenDir()); |
| 332 | setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getPluginConfig().getCodeGenDir(), |
| 333 | getJavaFileInfo().getPackageFilePath())); |
| 334 | } else { |
| 335 | setBaseCodePath(getJavaFileInfo().getBaseCodeGenPath()); |
| 336 | setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getBaseCodeGenPath(), |
| 337 | getJavaFileInfo().getPackageFilePath())); |
| 338 | } |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 339 | /* |
| 340 | * Initialize getter when generation file type matches to interface |
| 341 | * mask. |
| 342 | */ |
| 343 | if ((getGeneratedJavaFiles() & INTERFACE_MASK) != 0) { |
| 344 | addGeneratedTempFile(GETTER_FOR_INTERFACE_MASK); |
| 345 | } |
| 346 | |
| 347 | /* |
| 348 | * Initialize getter and setter when generation file type matches to |
| 349 | * builder interface mask. |
| 350 | */ |
| 351 | if ((getGeneratedJavaFiles() & BUILDER_INTERFACE_MASK) != 0) { |
| 352 | addGeneratedTempFile(GETTER_FOR_INTERFACE_MASK); |
| 353 | addGeneratedTempFile(SETTER_FOR_INTERFACE_MASK); |
| 354 | } |
| 355 | |
| 356 | /* |
| 357 | * Initialize getterImpl, setterImpl and attributes when generation file |
| 358 | * type matches to builder class mask. |
| 359 | */ |
| 360 | if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0) { |
| 361 | addGeneratedTempFile(ATTRIBUTES_MASK); |
| 362 | addGeneratedTempFile(GETTER_FOR_CLASS_MASK); |
| 363 | addGeneratedTempFile(SETTER_FOR_CLASS_MASK); |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | /* |
| 367 | * Initialize getterImpl, attributes, constructor, hash code, equals and |
| 368 | * to strings when generation file type matches to impl class mask. |
| 369 | */ |
| 370 | if ((getGeneratedJavaFiles() & IMPL_CLASS_MASK) != 0) { |
| 371 | addGeneratedTempFile(ATTRIBUTES_MASK); |
| 372 | addGeneratedTempFile(GETTER_FOR_CLASS_MASK); |
| 373 | addGeneratedTempFile(HASH_CODE_IMPL_MASK); |
| 374 | addGeneratedTempFile(EQUALS_IMPL_MASK); |
| 375 | addGeneratedTempFile(TO_STRING_IMPL_MASK); |
| 376 | } |
| 377 | |
| 378 | /* |
| 379 | * Initialize temp files to generate type class. |
| 380 | */ |
| 381 | if ((getGeneratedJavaFiles() & GENERATE_TYPE_CLASS) != 0) { |
| 382 | addGeneratedTempFile(ATTRIBUTES_MASK); |
| 383 | addGeneratedTempFile(GETTER_FOR_CLASS_MASK); |
| 384 | addGeneratedTempFile(HASH_CODE_IMPL_MASK); |
| 385 | addGeneratedTempFile(EQUALS_IMPL_MASK); |
| 386 | addGeneratedTempFile(TO_STRING_IMPL_MASK); |
| 387 | addGeneratedTempFile(FROM_STRING_IMPL_MASK); |
| 388 | } |
| 389 | |
| 390 | /* |
| 391 | * Initialize temp files to generate enum class. |
| 392 | */ |
| 393 | if ((getGeneratedJavaFiles() & GENERATE_ENUM_CLASS) != 0) { |
| 394 | addGeneratedTempFile(FROM_STRING_IMPL_MASK); |
| 395 | } |
| 396 | |
| 397 | /* |
| 398 | * Set temporary file handles. |
| 399 | */ |
| 400 | if ((getGeneratedTempFiles() & ATTRIBUTES_MASK) != 0) { |
| 401 | setAttributesTempFileHandle(getTemporaryFileHandle(ATTRIBUTE_FILE_NAME)); |
| 402 | } |
| 403 | |
| 404 | if ((getGeneratedTempFiles() & GETTER_FOR_INTERFACE_MASK) != 0) { |
| 405 | setGetterInterfaceTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_FILE_NAME)); |
| 406 | } |
| 407 | |
| 408 | if ((getGeneratedTempFiles() & SETTER_FOR_INTERFACE_MASK) != 0) { |
| 409 | setSetterInterfaceTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_FILE_NAME)); |
| 410 | } |
| 411 | |
| 412 | if ((getGeneratedTempFiles() & GETTER_FOR_CLASS_MASK) != 0) { |
| 413 | setGetterImplTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_IMPL_FILE_NAME)); |
| 414 | } |
| 415 | |
| 416 | if ((getGeneratedTempFiles() & SETTER_FOR_CLASS_MASK) != 0) { |
| 417 | setSetterImplTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_IMPL_FILE_NAME)); |
| 418 | } |
| 419 | |
| 420 | if ((getGeneratedTempFiles() & HASH_CODE_IMPL_MASK) != 0) { |
| 421 | setHashCodeImplTempFileHandle(getTemporaryFileHandle(HASH_CODE_METHOD_FILE_NAME)); |
| 422 | } |
| 423 | if ((getGeneratedTempFiles() & EQUALS_IMPL_MASK) != 0) { |
| 424 | setEqualsImplTempFileHandle(getTemporaryFileHandle(EQUALS_METHOD_FILE_NAME)); |
| 425 | } |
| 426 | if ((getGeneratedTempFiles() & TO_STRING_IMPL_MASK) != 0) { |
| 427 | setToStringImplTempFileHandle(getTemporaryFileHandle(TO_STRING_METHOD_FILE_NAME)); |
| 428 | } |
| 429 | if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) { |
| 430 | setFromStringImplTempFileHandle(getTemporaryFileHandle(FROM_STRING_METHOD_FILE_NAME)); |
| 431 | } |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | /** |
| 435 | * Adds current node info as and attribute to the parent generated file. |
| 436 | * |
| 437 | * @param curNode current node which needs to be added as an attribute in the parent generated code |
| 438 | * @param isList is list construct |
| 439 | * @param pluginConfig plugin configurations |
| 440 | * @throws IOException IO operation exception |
| 441 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 442 | static void addCurNodeInfoInParentTempFile(YangNode curNode, |
| 443 | boolean isList, YangPluginConfig pluginConfig) |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 444 | throws IOException { |
| 445 | YangNode parent = getParentNodeInGenCode(curNode); |
| 446 | if (!(parent instanceof JavaCodeGenerator)) { |
| 447 | throw new TranslatorException("missing parent node to contain current node info in generated file"); |
| 448 | } |
| 449 | |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 450 | if (parent instanceof YangJavaGroupingTranslator) { |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 451 | /* |
| 452 | * In case of grouping, there is no need to add the information, it |
| 453 | * will be taken care in uses |
| 454 | */ |
| 455 | return; |
| 456 | } |
| 457 | TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) parent) |
| 458 | .getTempJavaCodeFragmentFiles().getBeanTempFiles(); |
| 459 | |
| 460 | JavaAttributeInfo javaAttributeInfo = getCurNodeAsAttributeInTarget(curNode, |
| 461 | parent, isList, tempJavaBeanFragmentFiles); |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 462 | |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 463 | getNodesInterfaceFragmentFiles(parent, javaAttributeInfo, pluginConfig); |
| 464 | } |
| 465 | |
| 466 | /** |
| 467 | * Creates an attribute info object corresponding to a data model node and return it. |
| 468 | * |
| 469 | * @param curNode current data model node for which the java code generation is being handled |
| 470 | * @param targetNode target node in which the current node is an attribute |
| 471 | * @param isListNode is the current added attribute needs to be a list |
| 472 | * @param tempJavaFragmentFiles temp java fragment files |
| 473 | * @return AttributeInfo attribute details required to add in temporary files |
| 474 | */ |
| 475 | public static JavaAttributeInfo getCurNodeAsAttributeInTarget(YangNode curNode, |
| 476 | YangNode targetNode, boolean isListNode, |
| 477 | TempJavaFragmentFiles tempJavaFragmentFiles) { |
| 478 | String curNodeName = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName(); |
| 479 | if (curNodeName == null) { |
| 480 | updateJavaFileInfo(curNode, null); |
| 481 | curNodeName = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName(); |
| 482 | } |
| 483 | |
| 484 | /* |
| 485 | * Get the import info corresponding to the attribute for import in |
| 486 | * generated java files or qualified access |
| 487 | */ |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 488 | JavaQualifiedTypeInfoTranslator qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode, |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 489 | getCapitalCase(curNodeName)); |
| 490 | if (!(targetNode instanceof TempJavaCodeFragmentFilesContainer)) { |
| 491 | throw new TranslatorException("Parent node does not have file info"); |
| 492 | } |
| 493 | JavaImportData parentImportData = tempJavaFragmentFiles.getJavaImportData(); |
| 494 | JavaFileInfo fileInfo = ((JavaFileInfoContainer) targetNode).getJavaFileInfo(); |
| 495 | |
| 496 | boolean isQualified; |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 497 | if ((targetNode instanceof YangJavaModuleTranslator || targetNode instanceof YangJavaSubModuleTranslator) |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 498 | && (qualifiedTypeInfo.getClassInfo().contentEquals(SERVICE) |
| 499 | || qualifiedTypeInfo.getClassInfo().contentEquals(COMPONENT) |
| 500 | || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(ACTIVATE)) |
| 501 | || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(DEACTIVATE)) |
| 502 | || qualifiedTypeInfo.getClassInfo().contentEquals(REFERENCE_CARDINALITY) |
| 503 | || qualifiedTypeInfo.getClassInfo().contentEquals(REFERENCE)) |
| 504 | || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(fileInfo.getJavaName() + SERVICE)) |
| 505 | || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(fileInfo.getJavaName() + MANAGER))) { |
| 506 | |
| 507 | isQualified = true; |
| 508 | } else { |
| 509 | String className; |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 510 | if (targetNode instanceof YangJavaModuleTranslator || targetNode instanceof YangJavaSubModuleTranslator) { |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 511 | className = getCapitalCase(fileInfo.getJavaName()) + "Service"; |
| 512 | } else { |
| 513 | className = getCapitalCase(fileInfo.getJavaName()); |
| 514 | } |
| 515 | |
| 516 | isQualified = parentImportData.addImportInfo(qualifiedTypeInfo, |
| 517 | className, fileInfo.getPackage()); |
| 518 | } |
| 519 | |
| 520 | if (isListNode) { |
| 521 | parentImportData.setIfListImported(true); |
| 522 | } |
| 523 | |
| 524 | return getAttributeInfoForTheData(qualifiedTypeInfo, curNodeName, null, isQualified, isListNode); |
| 525 | } |
| 526 | |
| 527 | /** |
| 528 | * Adds java code snippet for corresponding files. |
| 529 | * |
| 530 | * @param node java node |
| 531 | * @param attr attribute info |
| 532 | * @param config plugin configurations |
| 533 | * @throws IOException when fails to do IO operations |
| 534 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 535 | private static void getNodesInterfaceFragmentFiles(YangNode node, JavaAttributeInfo attr, |
| 536 | YangPluginConfig config) throws IOException { |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 537 | TempJavaFragmentFiles tempJavaFragmentFiles; |
| 538 | JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) node).getJavaFileInfo(); |
| 539 | if ((javaFileInfo.getGeneratedFileTypes() & GENERATE_SERVICE_AND_MANAGER) != 0) { |
| 540 | tempJavaFragmentFiles = ((TempJavaCodeFragmentFilesContainer) node) |
| 541 | .getTempJavaCodeFragmentFiles() |
| 542 | .getServiceTempFiles(); |
| 543 | tempJavaFragmentFiles.addJavaSnippetInfoToApplicableTempFiles(attr, config); |
| 544 | } |
| 545 | if ((javaFileInfo.getGeneratedFileTypes() & GENERATE_INTERFACE_WITH_BUILDER) != 0) { |
| 546 | tempJavaFragmentFiles = ((TempJavaCodeFragmentFilesContainer) node) |
| 547 | .getTempJavaCodeFragmentFiles() |
| 548 | .getBeanTempFiles(); |
| 549 | tempJavaFragmentFiles.addJavaSnippetInfoToApplicableTempFiles(attr, config); |
| 550 | } |
| 551 | |
| 552 | } |
| 553 | |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 554 | /** |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 555 | * Returns java attribute for leaf. |
| 556 | * |
| 557 | * @param tempJavaFragmentFiles temporary generated file |
| 558 | * @param leaf YANG leaf |
| 559 | * @param yangPluginConfig plugin configurations |
| 560 | * @return java attribute for leaf |
| 561 | */ |
| 562 | public static JavaAttributeInfo getJavaAttributeOfLeaf(TempJavaFragmentFiles tempJavaFragmentFiles, YangLeaf leaf, |
| 563 | YangPluginConfig yangPluginConfig) { |
| 564 | JavaLeafInfoContainer javaLeaf = (JavaLeafInfoContainer) leaf; |
| 565 | javaLeaf.setConflictResolveConfig(yangPluginConfig.getConflictResolver()); |
| 566 | javaLeaf.updateJavaQualifiedInfo(); |
| 567 | return getAttributeInfoForTheData( |
| 568 | javaLeaf.getJavaQualifiedInfo(), |
| 569 | javaLeaf.getJavaName(yangPluginConfig.getConflictResolver()), |
| 570 | javaLeaf.getDataType(), |
| 571 | tempJavaFragmentFiles.getIsQualifiedAccessOrAddToImportList(javaLeaf.getJavaQualifiedInfo()), |
| 572 | false); |
| 573 | } |
| 574 | |
| 575 | /** |
| 576 | * Returns java attribute for leaf-list. |
| 577 | * |
| 578 | * @param tempJavaFragmentFiles temporary generated file |
| 579 | * @param leafList YANG leaf-list |
| 580 | * @param yangPluginConfig plugin configurations |
| 581 | * @return java attribute for leaf-list |
| 582 | */ |
| 583 | public static JavaAttributeInfo getJavaAttributeOfLeafList(TempJavaFragmentFiles tempJavaFragmentFiles, |
| 584 | YangLeafList leafList, |
| 585 | YangPluginConfig yangPluginConfig) { |
| 586 | JavaLeafInfoContainer javaLeaf = (JavaLeafInfoContainer) leafList; |
| 587 | javaLeaf.setConflictResolveConfig(yangPluginConfig.getConflictResolver()); |
| 588 | javaLeaf.updateJavaQualifiedInfo(); |
| 589 | tempJavaFragmentFiles.getJavaImportData().setIfListImported(true); |
| 590 | return getAttributeInfoForTheData( |
| 591 | javaLeaf.getJavaQualifiedInfo(), |
| 592 | javaLeaf.getJavaName(yangPluginConfig.getConflictResolver()), |
| 593 | javaLeaf.getDataType(), |
| 594 | tempJavaFragmentFiles.getIsQualifiedAccessOrAddToImportList(javaLeaf.getJavaQualifiedInfo()), |
| 595 | true); |
| 596 | } |
| 597 | |
| 598 | /** |
| 599 | * Retrieves the temporary file handle of op param builder class. |
| 600 | * |
| 601 | * @return op param builder temporary file handle |
| 602 | */ |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 603 | private File getBuilderOpParamClassJavaFileHandle() { |
| 604 | return builderOpParamClassJavaFileHandle; |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | /** |
| 608 | * Sets the java file handle for op param builder class. |
| 609 | * |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 610 | * @param builderOpParamClassJavaFileHandle java file handle |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 611 | */ |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 612 | private void setBuilderOpParamClassJavaFileHandle(File builderOpParamClassJavaFileHandle) { |
| 613 | this.builderOpParamClassJavaFileHandle = builderOpParamClassJavaFileHandle; |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | /** |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 617 | * Returns base code path. |
| 618 | * |
| 619 | * @return base code path |
| 620 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 621 | private String getBaseCodePath() { |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 622 | return baseCodePath; |
| 623 | } |
| 624 | |
| 625 | /** |
| 626 | * Sets base code path. |
| 627 | * |
| 628 | * @param baseCodePath base code path |
| 629 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 630 | void setBaseCodePath(String baseCodePath) { |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 631 | this.baseCodePath = baseCodePath; |
| 632 | } |
| 633 | |
| 634 | /* |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 635 | * Retrieves the absolute path where the file needs to be generated. |
| 636 | * |
| 637 | * @return absolute path where the file needs to be generated |
| 638 | */ |
| 639 | private String getAbsoluteDirPath() { |
| 640 | return absoluteDirPath; |
| 641 | } |
| 642 | |
| 643 | /** |
| 644 | * Sets absolute path where the file needs to be generated. |
| 645 | * |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 646 | * @param absoluteDirPath absolute path where the file needs to be generated. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 647 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 648 | void setAbsoluteDirPath(String absoluteDirPath) { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 649 | this.absoluteDirPath = absoluteDirPath; |
| 650 | } |
| 651 | |
| 652 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 653 | * Retrieves the generated java file information. |
| 654 | * |
| 655 | * @return generated java file information |
| 656 | */ |
| 657 | public JavaFileInfo getJavaFileInfo() { |
| 658 | return javaFileInfo; |
| 659 | } |
| 660 | |
| 661 | /** |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 662 | * Sets the generated java file information. |
| 663 | * |
| 664 | * @param javaFileInfo generated java file information |
| 665 | */ |
| 666 | public void setJavaFileInfo(JavaFileInfo javaFileInfo) { |
| 667 | this.javaFileInfo = javaFileInfo; |
| 668 | } |
| 669 | |
| 670 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 671 | * Retrieves the generated temp files. |
| 672 | * |
| 673 | * @return generated temp files |
| 674 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 675 | int getGeneratedTempFiles() { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 676 | return generatedTempFiles; |
| 677 | } |
| 678 | |
| 679 | /** |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 680 | * Sets generated file files. |
| 681 | * |
| 682 | * @param fileType generated file type |
| 683 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 684 | private void setGeneratedTempFiles(int fileType) { |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 685 | generatedTempFiles = fileType; |
| 686 | } |
| 687 | |
| 688 | /** |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 689 | * Adds to generated temporary files. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 690 | * |
| 691 | * @param generatedTempFile generated file |
| 692 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 693 | void addGeneratedTempFile(int generatedTempFile) { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 694 | generatedTempFiles |= generatedTempFile; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 695 | setGeneratedTempFiles(generatedTempFiles); |
| 696 | } |
| 697 | |
| 698 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 699 | * Retrieves the generated Java files. |
| 700 | * |
| 701 | * @return generated Java files |
| 702 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 703 | int getGeneratedJavaFiles() { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 704 | return getJavaFileInfo().getGeneratedFileTypes(); |
| 705 | } |
| 706 | |
| 707 | /** |
| 708 | * Retrieves the mapped Java class name. |
| 709 | * |
| 710 | * @return mapped Java class name |
| 711 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 712 | String getGeneratedJavaClassName() { |
janani b | 703cfe4 | 2016-05-17 13:12:22 +0530 | [diff] [blame] | 713 | return getCapitalCase(getJavaFileInfo().getJavaName()); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | /** |
| 717 | * Retrieves the import data for the generated Java file. |
| 718 | * |
| 719 | * @return import data for the generated Java file |
| 720 | */ |
| 721 | public JavaImportData getJavaImportData() { |
| 722 | return javaImportData; |
| 723 | } |
| 724 | |
| 725 | /** |
| 726 | * Sets import data for the generated Java file. |
| 727 | * |
| 728 | * @param javaImportData import data for the generated Java file |
| 729 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 730 | void setJavaImportData(JavaImportData javaImportData) { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 731 | this.javaImportData = javaImportData; |
| 732 | } |
| 733 | |
| 734 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 735 | * Retrieves the status of any attributes added. |
| 736 | * |
| 737 | * @return status of any attributes added |
| 738 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 739 | boolean isAttributePresent() { |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 740 | return isAttributePresent; |
| 741 | } |
| 742 | |
| 743 | /** |
| 744 | * Sets status of any attributes added. |
| 745 | * |
| 746 | * @param attributePresent status of any attributes added |
| 747 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 748 | private void setAttributePresent(boolean attributePresent) { |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 749 | isAttributePresent = attributePresent; |
| 750 | } |
| 751 | |
| 752 | /** |
| 753 | * Returns getter methods's temporary file handle. |
| 754 | * |
| 755 | * @return temporary file handle |
| 756 | */ |
| 757 | public File getGetterInterfaceTempFileHandle() { |
| 758 | return getterInterfaceTempFileHandle; |
| 759 | } |
| 760 | |
| 761 | /** |
| 762 | * Sets to getter method's temporary file handle. |
| 763 | * |
| 764 | * @param getterForInterface file handle for to getter method |
| 765 | */ |
| 766 | private void setGetterInterfaceTempFileHandle(File getterForInterface) { |
| 767 | getterInterfaceTempFileHandle = getterForInterface; |
| 768 | } |
| 769 | |
| 770 | /** |
| 771 | * Returns setter method's temporary file handle. |
| 772 | * |
| 773 | * @return temporary file handle |
| 774 | */ |
| 775 | public File getSetterInterfaceTempFileHandle() { |
| 776 | return setterInterfaceTempFileHandle; |
| 777 | } |
| 778 | |
| 779 | /** |
| 780 | * Sets to setter method's temporary file handle. |
| 781 | * |
| 782 | * @param setterForInterface file handle for to setter method |
| 783 | */ |
| 784 | private void setSetterInterfaceTempFileHandle(File setterForInterface) { |
| 785 | setterInterfaceTempFileHandle = setterForInterface; |
| 786 | } |
| 787 | |
| 788 | /** |
| 789 | * Returns setter method's impl's temporary file handle. |
| 790 | * |
| 791 | * @return temporary file handle |
| 792 | */ |
| 793 | public File getSetterImplTempFileHandle() { |
| 794 | return setterImplTempFileHandle; |
| 795 | } |
| 796 | |
| 797 | /** |
| 798 | * Sets to setter method's impl's temporary file handle. |
| 799 | * |
| 800 | * @param setterImpl file handle for to setter method's implementation class |
| 801 | */ |
| 802 | private void setSetterImplTempFileHandle(File setterImpl) { |
| 803 | setterImplTempFileHandle = setterImpl; |
| 804 | } |
| 805 | |
| 806 | /** |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 807 | * Returns from string method's temporary file handle. |
| 808 | * |
| 809 | * @return from string method's temporary file handle |
| 810 | */ |
| 811 | public File getFromStringImplTempFileHandle() { |
| 812 | return fromStringImplTempFileHandle; |
| 813 | } |
| 814 | |
| 815 | /** |
| 816 | * Sets from string method's temporary file handle. |
| 817 | * |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 818 | * @param fromStringImplTempFileHandle from string method's temporary file handle |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 819 | */ |
| 820 | private void setFromStringImplTempFileHandle(File fromStringImplTempFileHandle) { |
| 821 | this.fromStringImplTempFileHandle = fromStringImplTempFileHandle; |
| 822 | } |
| 823 | |
| 824 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 825 | * Returns java file handle for interface file. |
| 826 | * |
| 827 | * @return java file handle for interface file |
| 828 | */ |
| 829 | private File getInterfaceJavaFileHandle() { |
| 830 | return interfaceJavaFileHandle; |
| 831 | } |
| 832 | |
| 833 | /** |
| 834 | * Sets the java file handle for interface file. |
| 835 | * |
| 836 | * @param interfaceJavaFileHandle java file handle |
| 837 | */ |
| 838 | private void setInterfaceJavaFileHandle(File interfaceJavaFileHandle) { |
| 839 | this.interfaceJavaFileHandle = interfaceJavaFileHandle; |
| 840 | } |
| 841 | |
| 842 | /** |
| 843 | * Returns java file handle for builder interface file. |
| 844 | * |
| 845 | * @return java file handle for builder interface file |
| 846 | */ |
| 847 | private File getBuilderInterfaceJavaFileHandle() { |
| 848 | return builderInterfaceJavaFileHandle; |
| 849 | } |
| 850 | |
| 851 | /** |
| 852 | * Sets the java file handle for builder interface file. |
| 853 | * |
| 854 | * @param builderInterfaceJavaFileHandle java file handle |
| 855 | */ |
| 856 | private void setBuilderInterfaceJavaFileHandle(File builderInterfaceJavaFileHandle) { |
| 857 | this.builderInterfaceJavaFileHandle = builderInterfaceJavaFileHandle; |
| 858 | } |
| 859 | |
| 860 | /** |
| 861 | * Returns java file handle for builder class file. |
| 862 | * |
| 863 | * @return java file handle for builder class file |
| 864 | */ |
| 865 | private File getBuilderClassJavaFileHandle() { |
| 866 | return builderClassJavaFileHandle; |
| 867 | } |
| 868 | |
| 869 | /** |
| 870 | * Sets the java file handle for builder class file. |
| 871 | * |
| 872 | * @param builderClassJavaFileHandle java file handle |
| 873 | */ |
| 874 | private void setBuilderClassJavaFileHandle(File builderClassJavaFileHandle) { |
| 875 | this.builderClassJavaFileHandle = builderClassJavaFileHandle; |
| 876 | } |
| 877 | |
| 878 | /** |
| 879 | * Returns java file handle for impl class file. |
| 880 | * |
| 881 | * @return java file handle for impl class file |
| 882 | */ |
| 883 | private File getImplClassJavaFileHandle() { |
| 884 | return implClassJavaFileHandle; |
| 885 | } |
| 886 | |
| 887 | /** |
| 888 | * Sets the java file handle for impl class file. |
| 889 | * |
| 890 | * @param implClassJavaFileHandle java file handle |
| 891 | */ |
| 892 | private void setImplClassJavaFileHandle(File implClassJavaFileHandle) { |
| 893 | this.implClassJavaFileHandle = implClassJavaFileHandle; |
| 894 | } |
| 895 | |
| 896 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 897 | * Returns attribute's temporary file handle. |
| 898 | * |
| 899 | * @return temporary file handle |
| 900 | */ |
| 901 | public File getAttributesTempFileHandle() { |
| 902 | return attributesTempFileHandle; |
| 903 | } |
| 904 | |
| 905 | /** |
| 906 | * Sets attribute's temporary file handle. |
| 907 | * |
| 908 | * @param attributeForClass file handle for attribute |
| 909 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 910 | private void setAttributesTempFileHandle(File attributeForClass) { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 911 | attributesTempFileHandle = attributeForClass; |
| 912 | } |
| 913 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 914 | /** |
| 915 | * Returns getter method's impl's temporary file handle. |
| 916 | * |
| 917 | * @return temporary file handle |
| 918 | */ |
| 919 | public File getGetterImplTempFileHandle() { |
| 920 | return getterImplTempFileHandle; |
| 921 | } |
| 922 | |
| 923 | /** |
| 924 | * Sets to getter method's impl's temporary file handle. |
| 925 | * |
| 926 | * @param getterImpl file handle for to getter method's impl |
| 927 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 928 | private void setGetterImplTempFileHandle(File getterImpl) { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 929 | getterImplTempFileHandle = getterImpl; |
| 930 | } |
| 931 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 932 | /** |
| 933 | * Returns hash code method's temporary file handle. |
| 934 | * |
| 935 | * @return temporary file handle |
| 936 | */ |
| 937 | public File getHashCodeImplTempFileHandle() { |
| 938 | return hashCodeImplTempFileHandle; |
| 939 | } |
| 940 | |
| 941 | /** |
| 942 | * Sets hash code method's temporary file handle. |
| 943 | * |
| 944 | * @param hashCodeMethod file handle for hash code method |
| 945 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 946 | private void setHashCodeImplTempFileHandle(File hashCodeMethod) { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 947 | hashCodeImplTempFileHandle = hashCodeMethod; |
| 948 | } |
| 949 | |
| 950 | /** |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 951 | * Returns equals method's temporary file handle. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 952 | * |
| 953 | * @return temporary file handle |
| 954 | */ |
| 955 | public File getEqualsImplTempFileHandle() { |
| 956 | return equalsImplTempFileHandle; |
| 957 | } |
| 958 | |
| 959 | /** |
| 960 | * Sets equals method's temporary file handle. |
| 961 | * |
| 962 | * @param equalsMethod file handle for to equals method |
| 963 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 964 | private void setEqualsImplTempFileHandle(File equalsMethod) { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 965 | equalsImplTempFileHandle = equalsMethod; |
| 966 | } |
| 967 | |
| 968 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 969 | * Returns to string method's temporary file handle. |
| 970 | * |
| 971 | * @return temporary file handle |
| 972 | */ |
| 973 | public File getToStringImplTempFileHandle() { |
| 974 | return toStringImplTempFileHandle; |
| 975 | } |
| 976 | |
| 977 | /** |
| 978 | * Sets to string method's temporary file handle. |
| 979 | * |
| 980 | * @param toStringMethod file handle for to string method |
| 981 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 982 | private void setToStringImplTempFileHandle(File toStringMethod) { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 983 | toStringImplTempFileHandle = toStringMethod; |
| 984 | } |
| 985 | |
| 986 | /** |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 987 | * Returns java extends list holder. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 988 | * |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 989 | * @return java extends list holder |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 990 | */ |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 991 | public JavaExtendsListHolder getJavaExtendsListHolder() { |
| 992 | return javaExtendsListHolder; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 993 | } |
| 994 | |
| 995 | /** |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 996 | * Sets java extends list holder. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 997 | * |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 998 | * @param javaExtendsListHolder java extends list holder |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 999 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1000 | void setJavaExtendsListHolder(JavaExtendsListHolder javaExtendsListHolder) { |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 1001 | this.javaExtendsListHolder = javaExtendsListHolder; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1002 | } |
| 1003 | |
| 1004 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1005 | * Adds attribute for class. |
| 1006 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1007 | * @param attr attribute info |
| 1008 | * @param yangPluginConfig plugin configurations |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1009 | * @throws IOException when fails to append to temporary file |
| 1010 | */ |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1011 | private void addAttribute(JavaAttributeInfo attr, YangPluginConfig yangPluginConfig) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1012 | throws IOException { |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1013 | appendToFile(getAttributesTempFileHandle(), parseAttribute(attr, yangPluginConfig) |
| 1014 | + FOUR_SPACE_INDENTATION); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1015 | } |
| 1016 | |
| 1017 | /** |
| 1018 | * Adds getter for interface. |
| 1019 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1020 | * @param attr attribute info |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1021 | * @param pluginConfig plugin configurations |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1022 | * @throws IOException when fails to append to temporary file |
| 1023 | */ |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1024 | private void addGetterForInterface(JavaAttributeInfo attr, YangPluginConfig pluginConfig) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1025 | throws IOException { |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1026 | appendToFile(getGetterInterfaceTempFileHandle(), |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1027 | getGetterString(attr, getGeneratedJavaFiles(), pluginConfig) + NEW_LINE); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1028 | } |
| 1029 | |
| 1030 | /** |
| 1031 | * Adds setter for interface. |
| 1032 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1033 | * @param attr attribute info |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1034 | * @param pluginConfig plugin configurations |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1035 | * @throws IOException when fails to append to temporary file |
| 1036 | */ |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1037 | private void addSetterForInterface(JavaAttributeInfo attr, YangPluginConfig pluginConfig) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1038 | throws IOException { |
| 1039 | appendToFile(getSetterInterfaceTempFileHandle(), |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1040 | getSetterString(attr, getGeneratedJavaClassName(), getGeneratedJavaFiles(), pluginConfig) |
| 1041 | + NEW_LINE); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1042 | } |
| 1043 | |
| 1044 | /** |
| 1045 | * Adds setter's implementation for class. |
| 1046 | * |
| 1047 | * @param attr attribute info |
| 1048 | * @throws IOException when fails to append to temporary file |
| 1049 | */ |
| 1050 | private void addSetterImpl(JavaAttributeInfo attr) |
| 1051 | throws IOException { |
| 1052 | appendToFile(getSetterImplTempFileHandle(), |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1053 | getOverRideString() + getSetterForClass(attr, getGeneratedJavaClassName(), getGeneratedJavaFiles()) |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1054 | + NEW_LINE); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1055 | } |
| 1056 | |
| 1057 | /** |
| 1058 | * Adds getter method's impl for class. |
| 1059 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1060 | * @param attr attribute info |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1061 | * @param pluginConfig plugin configurations |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1062 | * @throws IOException when fails to append to temporary file |
| 1063 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1064 | void addGetterImpl(JavaAttributeInfo attr, YangPluginConfig pluginConfig) |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1065 | throws IOException { |
| 1066 | if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0 |
| 1067 | || (getGeneratedJavaFiles() & GENERATE_SERVICE_AND_MANAGER) != 0) { |
| 1068 | appendToFile(getGetterImplTempFileHandle(), getOverRideString() + getGetterForClass(attr, |
| 1069 | getGeneratedJavaFiles()) + NEW_LINE); |
| 1070 | } else { |
janani b | 703cfe4 | 2016-05-17 13:12:22 +0530 | [diff] [blame] | 1071 | appendToFile(getGetterImplTempFileHandle(), |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1072 | getJavaDoc(GETTER_METHOD, getCapitalCase(attr.getAttributeName()), false, pluginConfig) |
janani b | 703cfe4 | 2016-05-17 13:12:22 +0530 | [diff] [blame] | 1073 | + getGetterForClass(attr, getGeneratedJavaFiles()) + NEW_LINE); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1074 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1075 | } |
| 1076 | |
| 1077 | /** |
| 1078 | * Adds build method for interface. |
| 1079 | * |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1080 | * @param pluginConfig plugin configurations |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1081 | * @return build method for interface |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1082 | * @throws IOException when fails to append to temporary file |
| 1083 | */ |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1084 | String addBuildMethodForInterface(YangPluginConfig pluginConfig) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1085 | throws IOException { |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1086 | return parseBuilderInterfaceBuildMethodString(getGeneratedJavaClassName(), pluginConfig); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1087 | } |
| 1088 | |
| 1089 | /** |
| 1090 | * Adds build method's implementation for class. |
| 1091 | * |
| 1092 | * @return build method implementation for class |
| 1093 | * @throws IOException when fails to append to temporary file |
| 1094 | */ |
| 1095 | String addBuildMethodImpl() |
| 1096 | throws IOException { |
| 1097 | return getBuildString(getGeneratedJavaClassName()) + NEW_LINE; |
| 1098 | } |
| 1099 | |
| 1100 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1101 | * Adds default constructor for class. |
| 1102 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1103 | * @param modifier modifier for constructor. |
| 1104 | * @param toAppend string which need to be appended with the class name |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1105 | * @param pluginConfig plugin configurations |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1106 | * @return default constructor for class |
| 1107 | * @throws IOException when fails to append to file |
| 1108 | */ |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1109 | String addDefaultConstructor(String modifier, String toAppend, YangPluginConfig pluginConfig) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1110 | throws IOException { |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1111 | return NEW_LINE |
| 1112 | + getDefaultConstructorString(getGeneratedJavaClassName() + toAppend, modifier, pluginConfig); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1113 | } |
| 1114 | |
| 1115 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1116 | * Adds hash code method for class. |
| 1117 | * |
| 1118 | * @param attr attribute info |
| 1119 | * @throws IOException when fails to append to temporary file |
| 1120 | */ |
| 1121 | private void addHashCodeMethod(JavaAttributeInfo attr) |
| 1122 | throws IOException { |
| 1123 | appendToFile(getHashCodeImplTempFileHandle(), getHashCodeMethod(attr) + NEW_LINE); |
| 1124 | } |
| 1125 | |
| 1126 | /** |
| 1127 | * Adds equals method for class. |
| 1128 | * |
| 1129 | * @param attr attribute info |
| 1130 | * @throws IOException when fails to append to temporary file |
| 1131 | */ |
| 1132 | private void addEqualsMethod(JavaAttributeInfo attr) |
| 1133 | throws IOException { |
| 1134 | appendToFile(getEqualsImplTempFileHandle(), getEqualsMethod(attr) + NEW_LINE); |
| 1135 | } |
| 1136 | |
| 1137 | /** |
| 1138 | * Adds ToString method for class. |
| 1139 | * |
| 1140 | * @param attr attribute info |
| 1141 | * @throws IOException when fails to append to temporary file |
| 1142 | */ |
| 1143 | private void addToStringMethod(JavaAttributeInfo attr) |
| 1144 | throws IOException { |
| 1145 | appendToFile(getToStringImplTempFileHandle(), getToStringMethod(attr) + NEW_LINE); |
| 1146 | } |
| 1147 | |
| 1148 | /** |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1149 | * Adds from string method for union class. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1150 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1151 | * @param javaAttributeInfo type attribute info |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1152 | * @param fromStringAttributeInfo from string attribute info |
| 1153 | * @throws IOException when fails to append to temporary file |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1154 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1155 | void addFromStringMethod(JavaAttributeInfo javaAttributeInfo, |
| 1156 | JavaAttributeInfo fromStringAttributeInfo) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1157 | throws IOException { |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1158 | appendToFile(getFromStringImplTempFileHandle(), getFromStringMethod(javaAttributeInfo, |
| 1159 | fromStringAttributeInfo) + NEW_LINE); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1160 | } |
| 1161 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1162 | /** |
| 1163 | * Returns a temporary file handle for the specific file type. |
| 1164 | * |
| 1165 | * @param fileName file name |
| 1166 | * @return temporary file handle |
| 1167 | * @throws IOException when fails to create new file handle |
| 1168 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1169 | File getTemporaryFileHandle(String fileName) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1170 | throws IOException { |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1171 | String path = getTempDirPath(getAbsoluteDirPath()); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1172 | File dir = new File(path); |
| 1173 | if (!dir.exists()) { |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 1174 | boolean isCreated = dir.mkdirs(); |
| 1175 | if (!isCreated) { |
| 1176 | throw new IOException("failed to create temporary directory for " + fileName); |
| 1177 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1178 | } |
| 1179 | File file = new File(path + fileName + TEMP_FILE_EXTENSION); |
| 1180 | if (!file.exists()) { |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 1181 | boolean isCreated = file.createNewFile(); |
| 1182 | if (!isCreated) { |
| 1183 | throw new IOException("failed to create temporary files for " + fileName); |
| 1184 | } |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1185 | } else { |
| 1186 | throw new IOException(fileName + " is reused due to YANG naming"); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1187 | } |
| 1188 | return file; |
| 1189 | } |
| 1190 | |
| 1191 | /** |
| 1192 | * Returns a temporary file handle for the specific file type. |
| 1193 | * |
| 1194 | * @param fileName file name |
| 1195 | * @return temporary file handle |
| 1196 | * @throws IOException when fails to create new file handle |
| 1197 | */ |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1198 | File getJavaFileHandle(String fileName) |
| 1199 | throws IOException { |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1200 | return getFileObject(getDirPath(), fileName, JAVA_FILE_EXTENSION, getBaseCodePath()); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1201 | } |
| 1202 | |
| 1203 | /** |
| 1204 | * Returns data from the temporary files. |
| 1205 | * |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 1206 | * @param file temporary file handle |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1207 | * @param absolutePath absolute path |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1208 | * @return stored data from temporary files |
| 1209 | * @throws IOException when failed to get data from the given file |
| 1210 | */ |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1211 | public String getTemporaryDataFromFileHandle(File file, String absolutePath) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1212 | throws IOException { |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1213 | |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1214 | String path = getTempDirPath(absolutePath); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1215 | if (new File(path + file.getName()).exists()) { |
| 1216 | return readAppendFile(path + file.getName(), EMPTY_STRING); |
| 1217 | } else { |
| 1218 | throw new IOException("Unable to get data from the given " |
| 1219 | + file.getName() + " file for " + getGeneratedJavaClassName() + PERIOD); |
| 1220 | } |
| 1221 | } |
| 1222 | |
| 1223 | /** |
| 1224 | * Returns temporary directory path. |
| 1225 | * |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1226 | * @param absolutePath absolute path |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1227 | * @return directory path |
| 1228 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1229 | private String getTempDirPath(String absolutePath) { |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1230 | return getPackageDirPathFromJavaJPackage(absolutePath) + SLASH + getGeneratedJavaClassName() |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1231 | + TEMP_FOLDER_NAME_SUFFIX + SLASH; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1232 | } |
| 1233 | |
| 1234 | /** |
| 1235 | * Parses attribute to get the attribute string. |
| 1236 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1237 | * @param attr attribute info |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1238 | * @param pluginConfig plugin configurations |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1239 | * @return attribute string |
| 1240 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1241 | String parseAttribute(JavaAttributeInfo attr, YangPluginConfig pluginConfig) { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1242 | /* |
| 1243 | * TODO: check if this utility needs to be called or move to the caller |
| 1244 | */ |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1245 | String attributeName = getCamelCase(attr.getAttributeName(), pluginConfig.getConflictResolver()); |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1246 | String attributeAccessType = PRIVATE; |
| 1247 | if ((javaFileInfo.getGeneratedFileTypes() & GENERATE_INTERFACE_WITH_BUILDER) != 0) { |
| 1248 | attributeAccessType = PROTECTED; |
| 1249 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1250 | if (attr.isQualifiedName()) { |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1251 | return getJavaAttributeDefination(attr.getImportInfo().getPkgInfo(), |
| 1252 | attr.getImportInfo().getClassInfo(), |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1253 | attributeName, attr.isListAttr(), attributeAccessType); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1254 | } else { |
| 1255 | return getJavaAttributeDefination(null, attr.getImportInfo().getClassInfo(), attributeName, |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1256 | attr.isListAttr(), attributeAccessType); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1257 | } |
| 1258 | } |
| 1259 | |
| 1260 | /** |
| 1261 | * Appends content to temporary file. |
| 1262 | * |
| 1263 | * @param file temporary file |
| 1264 | * @param data data to be appended |
| 1265 | * @throws IOException when fails to append to file |
| 1266 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1267 | void appendToFile(File file, String data) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1268 | throws IOException { |
| 1269 | try { |
| 1270 | insertDataIntoJavaFile(file, data); |
| 1271 | } catch (IOException ex) { |
| 1272 | throw new IOException("failed to write in temp file."); |
| 1273 | } |
| 1274 | } |
| 1275 | |
| 1276 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1277 | * Adds parent's info to current node import list. |
| 1278 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1279 | * @param curNode current node for which import list needs to be updated |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1280 | * @param pluginConfig plugin configurations |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1281 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1282 | void addParentInfoInCurNodeTempFile(YangNode curNode, YangPluginConfig pluginConfig) { |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 1283 | caseImportInfo = new JavaQualifiedTypeInfoTranslator(); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1284 | YangNode parent = getParentNodeInGenCode(curNode); |
| 1285 | if (!(parent instanceof JavaCodeGenerator)) { |
| 1286 | throw new TranslatorException("missing parent node to contain current node info in generated file"); |
| 1287 | } |
| 1288 | if (!(curNode instanceof JavaFileInfoContainer)) { |
| 1289 | throw new TranslatorException("missing java file information to get the package details " |
| 1290 | + "of attribute corresponding to child node"); |
| 1291 | } |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1292 | caseImportInfo.setClassInfo(getCapitalCase(getCamelCase(parent.getName(), |
| 1293 | pluginConfig.getConflictResolver()))); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1294 | caseImportInfo.setPkgInfo(((JavaFileInfoContainer) parent).getJavaFileInfo().getPackage()); |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1295 | |
| 1296 | JavaFileInfo fileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); |
| 1297 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1298 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1299 | .getBeanTempFiles().getJavaImportData().addImportInfo(caseImportInfo, |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1300 | getCapitalCase(fileInfo.getJavaName()), fileInfo.getPackage()); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1301 | } |
| 1302 | |
| 1303 | /** |
| 1304 | * Adds leaf attributes in generated files. |
| 1305 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1306 | * @param listOfLeaves list of YANG leaf |
| 1307 | * @param yangPluginConfig plugin config |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1308 | * @param curNode current node |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1309 | * @throws IOException IO operation fail |
| 1310 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1311 | private void addLeavesInfoToTempFiles(List<YangLeaf> listOfLeaves, |
| 1312 | YangPluginConfig yangPluginConfig, YangNode curNode) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1313 | throws IOException { |
| 1314 | if (listOfLeaves != null) { |
| 1315 | for (YangLeaf leaf : listOfLeaves) { |
| 1316 | if (!(leaf instanceof JavaLeafInfoContainer)) { |
| 1317 | throw new TranslatorException("Leaf does not have java information"); |
| 1318 | } |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1319 | if (curNode instanceof YangModule || curNode instanceof YangSubModule) { |
| 1320 | TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) curNode) |
| 1321 | .getTempJavaCodeFragmentFiles().getBeanTempFiles(); |
| 1322 | addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeaf(tempJavaBeanFragmentFiles, leaf, |
| 1323 | yangPluginConfig), yangPluginConfig); |
| 1324 | } else { |
| 1325 | addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeaf(this, leaf, yangPluginConfig), |
| 1326 | yangPluginConfig); |
| 1327 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1328 | } |
| 1329 | } |
| 1330 | } |
| 1331 | |
| 1332 | /** |
| 1333 | * Adds leaf list's attributes in generated files. |
| 1334 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1335 | * @param listOfLeafList list of YANG leaves |
| 1336 | * @param yangPluginConfig plugin config |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1337 | * @param curNode current node |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1338 | * @throws IOException IO operation fail |
| 1339 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1340 | private void addLeafListInfoToTempFiles(List<YangLeafList> listOfLeafList, YangPluginConfig yangPluginConfig, |
| 1341 | YangNode curNode) throws IOException { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1342 | if (listOfLeafList != null) { |
| 1343 | for (YangLeafList leafList : listOfLeafList) { |
| 1344 | if (!(leafList instanceof JavaLeafInfoContainer)) { |
| 1345 | throw new TranslatorException("Leaf-list does not have java information"); |
| 1346 | } |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1347 | if (curNode instanceof YangModule || curNode instanceof YangSubModule) { |
| 1348 | TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) curNode) |
| 1349 | .getTempJavaCodeFragmentFiles().getBeanTempFiles(); |
| 1350 | addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeafList(tempJavaBeanFragmentFiles, |
| 1351 | leafList, yangPluginConfig), yangPluginConfig); |
| 1352 | } else { |
| 1353 | addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeafList(this, |
| 1354 | leafList, yangPluginConfig), yangPluginConfig); |
| 1355 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1356 | } |
| 1357 | } |
| 1358 | } |
| 1359 | |
| 1360 | /** |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1361 | * Adds all the leaves in the current data model node as part of the generated temporary file. |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1362 | * |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1363 | * @param curNode current node |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1364 | * @param yangPluginConfig plugin config |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1365 | * @throws IOException IO operation fail |
| 1366 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1367 | void addCurNodeLeavesInfoToTempFiles(YangNode curNode, |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 1368 | YangPluginConfig yangPluginConfig) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1369 | throws IOException { |
| 1370 | if (!(curNode instanceof YangLeavesHolder)) { |
| 1371 | throw new TranslatorException("Data model node does not have any leaves"); |
| 1372 | } |
| 1373 | YangLeavesHolder leavesHolder = (YangLeavesHolder) curNode; |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1374 | addLeavesInfoToTempFiles(leavesHolder.getListOfLeaf(), yangPluginConfig, curNode); |
| 1375 | addLeafListInfoToTempFiles(leavesHolder.getListOfLeafList(), yangPluginConfig, curNode); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1376 | } |
| 1377 | |
| 1378 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1379 | * Adds the new attribute info to the target generated temporary files. |
| 1380 | * |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 1381 | * @param newAttrInfo the attribute info that needs to be added to temporary files |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1382 | * @param pluginConfig plugin configurations |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1383 | * @throws IOException IO operation fail |
| 1384 | */ |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1385 | void addJavaSnippetInfoToApplicableTempFiles(JavaAttributeInfo newAttrInfo, YangPluginConfig pluginConfig) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1386 | throws IOException { |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1387 | setAttributePresent(true); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1388 | if ((getGeneratedTempFiles() & ATTRIBUTES_MASK) != 0) { |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1389 | addAttribute(newAttrInfo, pluginConfig); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1390 | } |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1391 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1392 | if ((getGeneratedTempFiles() & GETTER_FOR_INTERFACE_MASK) != 0) { |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1393 | addGetterForInterface(newAttrInfo, pluginConfig); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1394 | } |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1395 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1396 | if ((getGeneratedTempFiles() & SETTER_FOR_INTERFACE_MASK) != 0) { |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1397 | addSetterForInterface(newAttrInfo, pluginConfig); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1398 | } |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1399 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1400 | if ((getGeneratedTempFiles() & SETTER_FOR_CLASS_MASK) != 0) { |
| 1401 | addSetterImpl(newAttrInfo); |
| 1402 | } |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1403 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1404 | if ((getGeneratedTempFiles() & HASH_CODE_IMPL_MASK) != 0) { |
| 1405 | addHashCodeMethod(newAttrInfo); |
| 1406 | } |
| 1407 | if ((getGeneratedTempFiles() & EQUALS_IMPL_MASK) != 0) { |
| 1408 | addEqualsMethod(newAttrInfo); |
| 1409 | } |
| 1410 | if ((getGeneratedTempFiles() & TO_STRING_IMPL_MASK) != 0) { |
| 1411 | addToStringMethod(newAttrInfo); |
| 1412 | } |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1413 | |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1414 | if (!newAttrInfo.isIntConflict() && |
| 1415 | !newAttrInfo.isLongConflict()) { |
| 1416 | if ((getGeneratedTempFiles() & GETTER_FOR_CLASS_MASK) != 0) { |
| 1417 | addGetterImpl(newAttrInfo, pluginConfig); |
| 1418 | } |
| 1419 | |
| 1420 | if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) { |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 1421 | JavaQualifiedTypeInfoTranslator qualifiedInfoOfFromString = getQualifiedInfoOfFromString(newAttrInfo, |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1422 | pluginConfig.getConflictResolver()); |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1423 | /* |
| 1424 | * Create a new java attribute info with qualified information of |
| 1425 | * wrapper classes. |
| 1426 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1427 | JavaAttributeInfo fromStringAttributeInfo = getAttributeInfoForTheData(qualifiedInfoOfFromString, |
| 1428 | newAttrInfo.getAttributeName(), |
| 1429 | newAttrInfo.getAttributeType(), |
| 1430 | getIsQualifiedAccessOrAddToImportList(qualifiedInfoOfFromString), false); |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1431 | |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1432 | addFromStringMethod(newAttrInfo, fromStringAttributeInfo); |
| 1433 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1434 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1435 | } |
| 1436 | |
| 1437 | /** |
| 1438 | * Returns java class name. |
| 1439 | * |
| 1440 | * @param suffix for the class name based on the file type |
| 1441 | * @return java class name |
| 1442 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1443 | String getJavaClassName(String suffix) { |
janani b | 703cfe4 | 2016-05-17 13:12:22 +0530 | [diff] [blame] | 1444 | return getCapitalCase(getJavaFileInfo().getJavaName()) + suffix; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1445 | } |
| 1446 | |
| 1447 | /** |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1448 | * Returns java class name. |
| 1449 | * |
| 1450 | * @return java class name |
| 1451 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1452 | private String getImplClassName() { |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1453 | return getCapitalCase(DEFAULT) + getCapitalCase(getJavaFileInfo().getJavaName()); |
| 1454 | } |
| 1455 | |
| 1456 | /** |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1457 | * Returns op param java class name. |
| 1458 | * |
| 1459 | * @return op param java class name |
| 1460 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1461 | private String getOpParamImplClassName() { |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1462 | return getCapitalCase(getJavaFileInfo().getJavaName()) + OPERATION; |
| 1463 | } |
| 1464 | |
| 1465 | /** |
| 1466 | * Returns op param builder java class name. |
| 1467 | * |
| 1468 | * @return op param builder java class name |
| 1469 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1470 | private String getOpParamBuilderImplClassName() { |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1471 | return getCapitalCase(getJavaFileInfo().getJavaName()) + OPERATION + BUILDER; |
| 1472 | } |
| 1473 | |
| 1474 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1475 | * Returns the directory path. |
| 1476 | * |
| 1477 | * @return directory path |
| 1478 | */ |
| 1479 | private String getDirPath() { |
| 1480 | return getJavaFileInfo().getPackageFilePath(); |
| 1481 | } |
| 1482 | |
| 1483 | /** |
| 1484 | * Constructs java code exit. |
| 1485 | * |
| 1486 | * @param fileType generated file type |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1487 | * @param curNode current YANG node |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1488 | * @throws IOException when fails to generate java files |
| 1489 | */ |
| 1490 | public void generateJavaFile(int fileType, YangNode curNode) |
| 1491 | throws IOException { |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 1492 | |
| 1493 | if (curNode instanceof YangModule || curNode instanceof YangSubModule) { |
| 1494 | addResolvedAugmentedDataNodeImports(curNode); |
| 1495 | } |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1496 | TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) curNode) |
| 1497 | .getTempJavaCodeFragmentFiles().getBeanTempFiles(); |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 1498 | List<String> imports = ((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getBeanTempFiles() |
| 1499 | .getJavaImportData().getImports(); |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1500 | |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1501 | createPackage(curNode); |
| 1502 | |
| 1503 | /* |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1504 | * Generate java code. |
| 1505 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1506 | if ((fileType & INTERFACE_MASK) != 0 || (fileType & |
| 1507 | BUILDER_INTERFACE_MASK) != 0) { |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 1508 | |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1509 | /* |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1510 | * Create interface file. |
| 1511 | */ |
| 1512 | setInterfaceJavaFileHandle(getJavaFileHandle(getJavaClassName(INTERFACE_FILE_NAME_SUFFIX))); |
| 1513 | setInterfaceJavaFileHandle( |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1514 | generateInterfaceFile(getInterfaceJavaFileHandle(), imports, curNode, isAttributePresent())); |
| 1515 | /* |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1516 | * Create builder interface file. |
| 1517 | */ |
| 1518 | if ((fileType & BUILDER_INTERFACE_MASK) != 0) { |
| 1519 | setBuilderInterfaceJavaFileHandle( |
| 1520 | getJavaFileHandle(getJavaClassName(BUILDER_INTERFACE_FILE_NAME_SUFFIX))); |
| 1521 | setBuilderInterfaceJavaFileHandle( |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1522 | generateBuilderInterfaceFile(getBuilderInterfaceJavaFileHandle(), curNode, |
| 1523 | isAttributePresent())); |
| 1524 | /* |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1525 | * Append builder interface file to interface file and close it. |
| 1526 | */ |
| 1527 | mergeJavaFiles(getBuilderInterfaceJavaFileHandle(), getInterfaceJavaFileHandle()); |
Bharat saraswal | c2d3be1 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 1528 | validateLineLength(getInterfaceJavaFileHandle()); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1529 | } |
| 1530 | insertDataIntoJavaFile(getInterfaceJavaFileHandle(), getJavaClassDefClose()); |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1531 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1532 | if (curNode instanceof YangCase) { |
| 1533 | removeCaseImport(imports); |
| 1534 | } |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1535 | |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1536 | if (curNode instanceof YangAugment) { |
| 1537 | removeAugmentedInfoImport(imports); |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1538 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1539 | } |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1540 | if ((fileType & BUILDER_CLASS_MASK) != 0 || (fileType & IMPL_CLASS_MASK) != 0) { |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1541 | if (isAttributePresent()) { |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1542 | addImportsToStringAndHasCodeMethods(imports, true); |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 1543 | } |
| 1544 | if (curNode instanceof YangAugmentableNode) { |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1545 | addImportsForAugmentableClass(imports, true); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1546 | } |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1547 | sortImports(imports); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1548 | /* |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1549 | * Create impl class file. |
| 1550 | */ |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1551 | setImplClassJavaFileHandle(getJavaFileHandle(getImplClassName())); |
| 1552 | setImplClassJavaFileHandle( |
| 1553 | generateImplClassFile(getImplClassJavaFileHandle(), curNode, isAttributePresent(), imports)); |
| 1554 | |
| 1555 | /* |
| 1556 | * Create builder class file. |
| 1557 | */ |
| 1558 | if ((fileType & BUILDER_CLASS_MASK) != 0) { |
| 1559 | setBuilderClassJavaFileHandle(getJavaFileHandle(getJavaClassName(BUILDER_CLASS_FILE_NAME_SUFFIX))); |
| 1560 | setBuilderClassJavaFileHandle( |
| 1561 | generateBuilderClassFile(getBuilderClassJavaFileHandle(), curNode, |
| 1562 | isAttributePresent())); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1563 | /* |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1564 | * Append impl class to builder class and close it. |
| 1565 | */ |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1566 | mergeJavaFiles(getBuilderClassJavaFileHandle(), getImplClassJavaFileHandle()); |
| 1567 | validateLineLength(getImplClassJavaFileHandle()); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1568 | } |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1569 | insertDataIntoJavaFile(getImplClassJavaFileHandle(), getJavaClassDefClose()); |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1570 | if (curNode instanceof YangAugmentableNode) { |
| 1571 | addImportsForAugmentableClass(imports, false); |
| 1572 | } |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1573 | if (!(curNode instanceof YangModule)) { |
| 1574 | if (isAttributePresent()) { |
| 1575 | addImportsToStringAndHasCodeMethods(imports, false); |
| 1576 | } |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1577 | if (curNode instanceof YangAugmentableNode) { |
| 1578 | addYangAugmentedOpParamInfoImport(imports); |
| 1579 | } |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 1580 | JavaQualifiedTypeInfoTranslator qualifiedTypeInfo = new JavaQualifiedTypeInfoTranslator(); |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1581 | qualifiedTypeInfo.setClassInfo(getCapitalCase(DEFAULT) + getCapitalCase(getJavaFileInfo() |
| 1582 | .getJavaName())); |
| 1583 | qualifiedTypeInfo.setPkgInfo(getJavaFileInfo().getPackage()); |
| 1584 | getJavaExtendsListHolder().addToExtendsList(qualifiedTypeInfo, curNode, |
| 1585 | tempJavaBeanFragmentFiles); |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1586 | addBitSetImport(imports, true); |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1587 | if (curNode instanceof YangAugment) { |
| 1588 | addYangAugmentedOpParamInfoImport(imports); |
| 1589 | } |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1590 | /* |
| 1591 | * Create impl class file. |
| 1592 | */ |
| 1593 | setOpParamClassJavaFileHandle(getJavaFileHandle(getOpParamImplClassName())); |
| 1594 | setOpParamClassJavaFileHandle( |
| 1595 | generateOpParamImplClassFile(getOpParamClassJavaFileHandle(), curNode, |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1596 | isAttributePresent(), imports)); |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1597 | |
| 1598 | /* |
| 1599 | * Create builder class file. |
| 1600 | */ |
| 1601 | if ((fileType & BUILDER_CLASS_MASK) != 0) { |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 1602 | setBuilderOpParamClassJavaFileHandle(getJavaFileHandle(getOpParamBuilderImplClassName())); |
| 1603 | setBuilderOpParamClassJavaFileHandle( |
| 1604 | generateOpParamBuilderClassFile(getBuilderOpParamClassJavaFileHandle(), curNode, |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1605 | isAttributePresent())); |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1606 | /* |
| 1607 | * Append impl class to builder class and close it. |
| 1608 | */ |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 1609 | mergeJavaFiles(getBuilderOpParamClassJavaFileHandle(), getOpParamClassJavaFileHandle()); |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1610 | validateLineLength(getOpParamClassJavaFileHandle()); |
| 1611 | |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1612 | addBitSetImport(imports, false); |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1613 | } |
| 1614 | insertDataIntoJavaFile(getOpParamClassJavaFileHandle(), getJavaClassDefClose()); |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1615 | |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1616 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1617 | } |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1618 | /* |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1619 | * Close all the file handles. |
| 1620 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1621 | freeTemporaryResources(false); |
| 1622 | } |
| 1623 | |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1624 | /*Adds import for YANG augmented op param info.*/ |
| 1625 | private void addYangAugmentedOpParamInfoImport(List<String> imports) { |
| 1626 | imports.add(getJavaImportData().getYangAugmentedOpParamInfoImport()); |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1627 | } |
| 1628 | |
| 1629 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1630 | * Adds imports for ToString and HashCodeMethod. |
| 1631 | * |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1632 | * @param imports import list |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1633 | * @param operation add or remove |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1634 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1635 | void addImportsToStringAndHasCodeMethods(List<String> imports, boolean operation) { |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1636 | if (operation) { |
| 1637 | imports.add(getJavaImportData().getImportForHashAndEquals()); |
| 1638 | imports.add(getJavaImportData().getImportForToString()); |
| 1639 | } else { |
| 1640 | imports.remove(getJavaImportData().getImportForHashAndEquals()); |
| 1641 | imports.remove(getJavaImportData().getImportForToString()); |
| 1642 | } |
| 1643 | } |
| 1644 | |
| 1645 | /** |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1646 | * Adds imports for bitSet method. |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1647 | * |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1648 | * @param imports import list |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1649 | * @param operation add or remove |
| 1650 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1651 | private void addBitSetImport(List<String> imports, boolean operation) { |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1652 | if (operation) { |
| 1653 | imports.add(getJavaImportData().getImportForToBitSet()); |
| 1654 | } else { |
| 1655 | imports.remove(getJavaImportData().getImportForToBitSet()); |
| 1656 | } |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 1657 | } |
| 1658 | |
| 1659 | |
| 1660 | /** |
| 1661 | * Adds import for map and hash map. |
| 1662 | * |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1663 | * @param imports import list |
| 1664 | * @param operations true for adding and false for deletion |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 1665 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1666 | private void addImportsForAugmentableClass(List<String> imports, boolean operations) { |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1667 | if (operations) { |
| 1668 | imports.add(getJavaImportData().getHashMapImport()); |
| 1669 | imports.add(getJavaImportData().getMapImport()); |
| 1670 | imports.add(getJavaImportData().getYangAugmentedInfoImport()); |
| 1671 | } else { |
| 1672 | imports.remove(getJavaImportData().getHashMapImport()); |
| 1673 | imports.remove(getJavaImportData().getMapImport()); |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1674 | } |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1675 | } |
| 1676 | |
| 1677 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1678 | * Removes case import info from import list. |
| 1679 | * |
| 1680 | * @param imports list of imports |
| 1681 | * @return import for class |
| 1682 | */ |
| 1683 | private List<String> removeCaseImport(List<String> imports) { |
| 1684 | if (imports != null && caseImportInfo != null) { |
| 1685 | String caseImport = IMPORT + caseImportInfo.getPkgInfo() + PERIOD + caseImportInfo.getClassInfo() + |
| 1686 | SEMI_COLAN + NEW_LINE; |
| 1687 | imports.remove(caseImport); |
| 1688 | } |
| 1689 | return imports; |
| 1690 | } |
| 1691 | |
| 1692 | /** |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1693 | * Removes case import info from import list. |
| 1694 | * |
| 1695 | * @param imports list of imports |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1696 | */ |
| 1697 | private void removeAugmentedInfoImport(List<String> imports) { |
| 1698 | imports.remove(getJavaImportData().getYangAugmentedInfoImport()); |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 1699 | for (JavaQualifiedTypeInfoTranslator type : getJavaImportData().getImportSet()) { |
Vidyashree Rama | 72719fa | 2016-07-15 14:06:56 +0530 | [diff] [blame] | 1700 | if (type.getClassInfo().equals(YANG_AUGMENTED_INFO)) { |
| 1701 | getJavaImportData().getImportSet().remove(type); |
| 1702 | getJavaExtendsListHolder().getExtendsList().remove(type); |
| 1703 | } |
| 1704 | } |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1705 | } |
| 1706 | |
| 1707 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1708 | * Removes all temporary file handles. |
| 1709 | * |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1710 | * @param isErrorOccurred flag to tell translator that error has occurred while file generation |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1711 | * @throws IOException when failed to delete the temporary files |
| 1712 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1713 | public void freeTemporaryResources(boolean isErrorOccurred) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1714 | throws IOException { |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1715 | /* |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1716 | * Close all java file handles and when error occurs delete the files. |
| 1717 | */ |
| 1718 | if ((getGeneratedJavaFiles() & INTERFACE_MASK) != 0) { |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1719 | closeFile(getInterfaceJavaFileHandle(), isErrorOccurred); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1720 | } |
| 1721 | if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0) { |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1722 | closeFile(getBuilderClassJavaFileHandle(), true); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1723 | } |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1724 | if ((getGeneratedJavaFiles() & OPERATION_BUILDER_CLASS_MASK) != 0) { |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 1725 | closeFile(getBuilderOpParamClassJavaFileHandle(), true); |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1726 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1727 | if ((getGeneratedJavaFiles() & BUILDER_INTERFACE_MASK) != 0) { |
| 1728 | closeFile(getBuilderInterfaceJavaFileHandle(), true); |
| 1729 | } |
| 1730 | if ((getGeneratedJavaFiles() & IMPL_CLASS_MASK) != 0) { |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1731 | closeFile(getImplClassJavaFileHandle(), isErrorOccurred); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1732 | } |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1733 | |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1734 | /* |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1735 | * Close all temporary file handles and delete the files. |
| 1736 | */ |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1737 | if ((getGeneratedTempFiles() & GETTER_FOR_CLASS_MASK) != 0) { |
| 1738 | closeFile(getGetterImplTempFileHandle(), true); |
| 1739 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1740 | if ((getGeneratedTempFiles() & ATTRIBUTES_MASK) != 0) { |
| 1741 | closeFile(getAttributesTempFileHandle(), true); |
| 1742 | } |
| 1743 | if ((getGeneratedTempFiles() & HASH_CODE_IMPL_MASK) != 0) { |
| 1744 | closeFile(getHashCodeImplTempFileHandle(), true); |
| 1745 | } |
| 1746 | if ((getGeneratedTempFiles() & TO_STRING_IMPL_MASK) != 0) { |
| 1747 | closeFile(getToStringImplTempFileHandle(), true); |
| 1748 | } |
| 1749 | if ((getGeneratedTempFiles() & EQUALS_IMPL_MASK) != 0) { |
| 1750 | closeFile(getEqualsImplTempFileHandle(), true); |
| 1751 | } |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1752 | if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) { |
| 1753 | closeFile(getFromStringImplTempFileHandle(), true); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1754 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1755 | } |
| 1756 | |
| 1757 | /** |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 1758 | * Returns if the attribute needs to be accessed in a qualified manner or not, if it needs to be imported, then the |
| 1759 | * same needs to be done. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1760 | * |
| 1761 | * @param importInfo import info for the current attribute being added |
| 1762 | * @return status of the qualified access to the attribute |
| 1763 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1764 | boolean getIsQualifiedAccessOrAddToImportList( |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame^] | 1765 | JavaQualifiedTypeInfoTranslator importInfo) { |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1766 | |
| 1767 | return getJavaImportData().addImportInfo(importInfo, getGeneratedJavaClassName(), |
| 1768 | getJavaFileInfo().getPackage()); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1769 | } |
| 1770 | |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1771 | /** |
| 1772 | * Returns java file handle for op param class file. |
| 1773 | * |
| 1774 | * @return java file handle for op param class file |
| 1775 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1776 | private File getOpParamClassJavaFileHandle() { |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1777 | return opParamClassJavaFileHandle; |
| 1778 | } |
| 1779 | |
| 1780 | /** |
| 1781 | * Sets the java file handle for op param class file. |
| 1782 | * |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1783 | * @param opParamClassJavaFileHandle java file handle |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1784 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1785 | private void setOpParamClassJavaFileHandle(File opParamClassJavaFileHandle) { |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1786 | this.opParamClassJavaFileHandle = opParamClassJavaFileHandle; |
| 1787 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1788 | } |