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