Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 0f7908b | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.yangutils.translator.tojava; |
| 17 | |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 18 | import java.util.ArrayList; |
| 19 | import java.util.List; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 20 | import java.util.SortedSet; |
| 21 | import java.util.TreeSet; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 22 | |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 23 | import static java.util.Collections.sort; |
| 24 | import static java.util.Collections.unmodifiableSortedSet; |
| 25 | import static org.onosproject.yangutils.translator.tojava.utils.StringGenerator.getImportString; |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 26 | import static org.onosproject.yangutils.utils.UtilConstants.ABSTRACT_EVENT; |
Bharat saraswal | 51c5d67 | 2016-11-13 09:03:48 +0530 | [diff] [blame] | 27 | import static org.onosproject.yangutils.utils.UtilConstants.ARRAY_LIST_IMPORT; |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 28 | import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER; |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 29 | import static org.onosproject.yangutils.utils.UtilConstants.BITSET; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 30 | import static org.onosproject.yangutils.utils.UtilConstants.COLLECTION_IMPORTS; |
| 31 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 32 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 33 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_LANG; |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 34 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_MATH; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 35 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_OBJECTS_IMPORT_CLASS; |
Bharat saraswal | 54e4bab | 2016-10-05 23:32:14 +0530 | [diff] [blame] | 36 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_PKG; |
| 37 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_REGEX_PKG; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 38 | import static org.onosproject.yangutils.utils.UtilConstants.LIST; |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 39 | import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 40 | import static org.onosproject.yangutils.utils.UtilConstants.MAP; |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 41 | import static org.onosproject.yangutils.utils.UtilConstants.ONOS_EVENT_PKG; |
Bharat saraswal | 54e4bab | 2016-10-05 23:32:14 +0530 | [diff] [blame] | 42 | import static org.onosproject.yangutils.utils.UtilConstants.PATTERN; |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 43 | import static org.onosproject.yangutils.utils.UtilConstants.QUEUE; |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 44 | import static org.onosproject.yangutils.utils.UtilConstants.SET; |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 45 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 46 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 47 | * Represents that generated Java file can contain imports. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 48 | */ |
| 49 | public class JavaImportData { |
| 50 | |
| 51 | /** |
| 52 | * Flag to denote if any list in imported. |
| 53 | */ |
| 54 | private boolean isListToImport; |
| 55 | |
| 56 | /** |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 57 | * Flag to denote if any queue is imported due to compiler annotation. |
| 58 | */ |
| 59 | private boolean isQueueToImport; |
| 60 | |
| 61 | /** |
| 62 | * Flag to denote if any set is imported due to compiler annotation. |
| 63 | */ |
| 64 | private boolean isSetToImport; |
| 65 | |
| 66 | /** |
Bharat saraswal | a5c2851 | 2016-11-10 21:09:23 +0530 | [diff] [blame] | 67 | * Flag to denote if any map is imported due to compiler annotation. |
| 68 | */ |
| 69 | private boolean isMapToImport; |
| 70 | |
| 71 | /** |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 72 | * Sorted set of import info, to be used to maintain the set of classes to |
| 73 | * be imported in the generated class. |
| 74 | */ |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 75 | private final SortedSet<JavaQualifiedTypeInfoTranslator> importSet; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 76 | |
| 77 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 78 | * Creates java import data object. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 79 | */ |
| 80 | public JavaImportData() { |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 81 | importSet = new TreeSet<>(); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 82 | } |
| 83 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 84 | |
| 85 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 86 | * Sets the status of importing list. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 87 | * |
Vidyashree Rama | 02f115f | 2016-04-18 12:29:39 +0530 | [diff] [blame] | 88 | * @param isList status to mention list is bing imported |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 89 | */ |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 90 | void setIfListImported(boolean isList) { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 91 | isListToImport = isList; |
| 92 | } |
| 93 | |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 94 | |
| 95 | /** |
| 96 | * Sets the status of the queue to be imported due to compiler annotations. |
| 97 | * |
| 98 | * @param queueToImport status of queue to import |
| 99 | */ |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 100 | void setQueueToImport(boolean queueToImport) { |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 101 | isQueueToImport = queueToImport; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Sets the status of the set to be imported due to compiler annotations. |
| 106 | * |
| 107 | * @param setToImport status of set to import |
| 108 | */ |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 109 | void setSetToImport(boolean setToImport) { |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 110 | isSetToImport = setToImport; |
| 111 | } |
| 112 | |
| 113 | /** |
Bharat saraswal | a5c2851 | 2016-11-10 21:09:23 +0530 | [diff] [blame] | 114 | * Sets true if map is imported due to compiler annotations. |
| 115 | * |
| 116 | * @param mapToImport true if map is imported due to compiler annotations |
| 117 | */ |
| 118 | void setMapToImport(boolean mapToImport) { |
| 119 | isMapToImport = mapToImport; |
| 120 | } |
| 121 | |
| 122 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 123 | * Returns the set containing the imported class/interface info. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 124 | * |
| 125 | * @return the set containing the imported class/interface info |
| 126 | */ |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 127 | public SortedSet<JavaQualifiedTypeInfoTranslator> getImportSet() { |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 128 | return unmodifiableSortedSet(importSet); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | /** |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 132 | * Adds an imported class/interface info if it is not already part of the |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 133 | * collection. |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 134 | * <p> |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 135 | * If already part of the collection, check if the packages are same, if so |
| 136 | * then return true, to denote it is already in the import collection, and |
| 137 | * it can be accessed without qualified access. If the packages do not |
| 138 | * match, then do not add to the import collection, and return false to |
| 139 | * denote, it is not added to import collection and needs to be accessed in |
| 140 | * a qualified manner. |
| 141 | * |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 142 | * @param newImportInfo class/interface info being imported |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 143 | * @param className name of the call being generated |
| 144 | * @param classPkg generated class package |
| 145 | * @return qualified access status of the import node being added |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 146 | */ |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 147 | public boolean addImportInfo(JavaQualifiedTypeInfoTranslator newImportInfo, |
| 148 | String className, String classPkg) { |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 149 | |
| 150 | if (newImportInfo.getClassInfo().contentEquals(className)) { |
| 151 | /* |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 152 | * If the current class name is same as the attribute class name, |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 153 | * then the attribute must be accessed in a qualified manner. |
| 154 | */ |
| 155 | return true; |
| 156 | } else if (newImportInfo.getPkgInfo() == null) { |
| 157 | /* |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 158 | * If the package info is null, then it is not a candidate for import |
| 159 | * / qualified access |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 160 | */ |
| 161 | return false; |
| 162 | } |
| 163 | |
| 164 | /* |
| 165 | * If the attribute type is having the package info, it is contender |
| 166 | * for import list and also need to check if it needs to be a |
| 167 | * qualified access. |
| 168 | */ |
| 169 | if (newImportInfo.getPkgInfo().contentEquals(classPkg)) { |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 170 | /* |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 171 | * Package of the referred attribute and the generated class is same, |
| 172 | * so no need import |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 173 | * or qualified access. |
| 174 | */ |
| 175 | return false; |
| 176 | } |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 177 | |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 178 | for (JavaQualifiedTypeInfoTranslator curImportInfo : getImportSet()) { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 179 | if (curImportInfo.getClassInfo() |
| 180 | .contentEquals(newImportInfo.getClassInfo())) { |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 181 | return !curImportInfo.getPkgInfo() |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 182 | .contentEquals(newImportInfo.getPkgInfo()); |
| 183 | } |
| 184 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 185 | |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 186 | /* |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 187 | * Import is added, so it is a member for non qualified access |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 188 | */ |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 189 | importSet.add(newImportInfo); |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 190 | return false; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 191 | } |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 192 | |
| 193 | /** |
| 194 | * Returns import for class. |
| 195 | * |
Bharat saraswal | 51c5d67 | 2016-11-13 09:03:48 +0530 | [diff] [blame] | 196 | * @param isForInterface if needs to check for interface |
Vidyashree Rama | 1396065 | 2016-04-26 15:06:06 +0530 | [diff] [blame] | 197 | * @return imports for class |
| 198 | */ |
Bharat saraswal | 51c5d67 | 2016-11-13 09:03:48 +0530 | [diff] [blame] | 199 | public List<String> getImports(boolean isForInterface) { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 200 | |
Vidyashree Rama | 1396065 | 2016-04-26 15:06:06 +0530 | [diff] [blame] | 201 | String importString; |
| 202 | List<String> imports = new ArrayList<>(); |
Bharat saraswal | 51c5d67 | 2016-11-13 09:03:48 +0530 | [diff] [blame] | 203 | boolean check; |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 204 | for (JavaQualifiedTypeInfoTranslator importInfo : getImportSet()) { |
Bharat saraswal | 51c5d67 | 2016-11-13 09:03:48 +0530 | [diff] [blame] | 205 | check = importInfo.isForInterface(); |
| 206 | if (!isForInterface) { |
| 207 | check = true; |
| 208 | } |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 209 | if (!importInfo.getPkgInfo().equals(EMPTY_STRING) && |
| 210 | importInfo.getClassInfo() != null && |
Bharat saraswal | 51c5d67 | 2016-11-13 09:03:48 +0530 | [diff] [blame] | 211 | !importInfo.getPkgInfo().equals(JAVA_LANG) && |
| 212 | check) { |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 213 | importString = getImportString(importInfo.getPkgInfo(), importInfo |
| 214 | .getClassInfo()); |
Vidyashree Rama | 1396065 | 2016-04-26 15:06:06 +0530 | [diff] [blame] | 215 | imports.add(importString); |
| 216 | } |
| 217 | } |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 218 | if (isListToImport) { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 219 | imports.add(getImportForList()); |
Bharat saraswal | 51c5d67 | 2016-11-13 09:03:48 +0530 | [diff] [blame] | 220 | if (!isForInterface) { |
| 221 | imports.add(ARRAY_LIST_IMPORT); |
| 222 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 223 | } |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 224 | if (isQueueToImport) { |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 225 | imports.add(getImportForQueue()); |
| 226 | } |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 227 | if (isSetToImport) { |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 228 | imports.add(getImportForSet()); |
| 229 | } |
Bharat saraswal | a5c2851 | 2016-11-10 21:09:23 +0530 | [diff] [blame] | 230 | if (isMapToImport) { |
| 231 | imports.add(getImportForMap()); |
| 232 | } |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 233 | |
Vidyashree Rama | 1396065 | 2016-04-26 15:06:06 +0530 | [diff] [blame] | 234 | sort(imports); |
| 235 | return imports; |
| 236 | } |
| 237 | |
| 238 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 239 | * Returns import for hash and equals method. |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 240 | * |
| 241 | * @return import for hash and equals method |
| 242 | */ |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 243 | String getImportForHashAndEquals() { |
Bharat saraswal | 54e4bab | 2016-10-05 23:32:14 +0530 | [diff] [blame] | 244 | return getImportString(JAVA_UTIL_PKG, |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 245 | JAVA_UTIL_OBJECTS_IMPORT_CLASS); |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | /** |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 249 | * Returns import for to bitset method. |
| 250 | * |
| 251 | * @return import for to bitset method |
| 252 | */ |
Bharat saraswal | 54e4bab | 2016-10-05 23:32:14 +0530 | [diff] [blame] | 253 | public String getImportForToBitSet() { |
| 254 | return getImportString(JAVA_UTIL_PKG, BITSET); |
| 255 | } |
| 256 | |
| 257 | /** |
| 258 | * Returns import for to bitset method. |
| 259 | * |
| 260 | * @return import for to bitset method |
| 261 | */ |
| 262 | public String getImportForPattern() { |
| 263 | return getImportString(JAVA_UTIL_REGEX_PKG, PATTERN); |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 267 | * Returns import for list attribute. |
| 268 | * |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 269 | * @return import for list attribute |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 270 | */ |
Bharat saraswal | 51c5d67 | 2016-11-13 09:03:48 +0530 | [diff] [blame] | 271 | private String getImportForList() { |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 272 | return getImportString(COLLECTION_IMPORTS, LIST); |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 273 | } |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 274 | |
| 275 | /** |
Bharat saraswal | a5c2851 | 2016-11-10 21:09:23 +0530 | [diff] [blame] | 276 | * Returns import for map attribute. |
| 277 | * |
| 278 | * @return import for map attribute |
| 279 | */ |
| 280 | private String getImportForMap() { |
| 281 | return getImportString(COLLECTION_IMPORTS, MAP); |
| 282 | } |
| 283 | |
| 284 | /** |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 285 | * Returns import for queue attribute. |
| 286 | * |
| 287 | * @return import for queue attribute |
| 288 | */ |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 289 | private String getImportForQueue() { |
| 290 | return getImportString(COLLECTION_IMPORTS, QUEUE); |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | /** |
| 294 | * Returns import for set attribute. |
| 295 | * |
| 296 | * @return import for set attribute |
| 297 | */ |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 298 | private String getImportForSet() { |
| 299 | return getImportString(COLLECTION_IMPORTS, SET); |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | /** |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 303 | * Returns import string for ListenerService class. |
| 304 | * |
| 305 | * @return import string for ListenerService class |
| 306 | */ |
| 307 | public String getListenerServiceImport() { |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 308 | return getImportString(ONOS_EVENT_PKG, LISTENER_SERVICE); |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | /** |
| 312 | * Returns import string for AbstractEvent class. |
| 313 | * |
| 314 | * @return import string for AbstractEvent class |
| 315 | */ |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 316 | String getAbstractEventsImport() { |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 317 | return getImportString(ONOS_EVENT_PKG, ABSTRACT_EVENT); |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | /** |
| 321 | * Returns import string for EventListener class. |
| 322 | * |
| 323 | * @return import string for EventListener class |
| 324 | */ |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 325 | String getEventListenerImport() { |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 326 | return getImportString(ONOS_EVENT_PKG, EVENT_LISTENER); |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 327 | } |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 328 | |
| 329 | /** |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 330 | * Returns import for big integer. |
| 331 | * |
| 332 | * @return import for big integer |
| 333 | */ |
| 334 | public String getBigIntegerImport() { |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 335 | return getImportString(JAVA_MATH, BIG_INTEGER); |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 336 | } |
Bharat saraswal | 9fab16b | 2016-09-23 23:27:24 +0530 | [diff] [blame] | 337 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 338 | } |