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 | |
| 17 | package org.onosproject.yangutils.translator.tojava; |
| 18 | |
Bharat saraswal | c2d3be1 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 19 | import java.io.Serializable; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 20 | import java.util.Objects; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 21 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 22 | import org.onosproject.yangutils.datamodel.YangNode; |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 23 | import org.onosproject.yangutils.datamodel.javadatamodel.JavaQualifiedTypeInfo; |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 24 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 25 | import org.onosproject.yangutils.translator.tojava.javamodel |
| 26 | .AttributesJavaDataType; |
| 27 | import org.onosproject.yangutils.translator.tojava.javamodel |
| 28 | .JavaLeafInfoContainer; |
Bharat saraswal | 2da23bf | 2016-08-25 15:28:39 +0530 | [diff] [blame] | 29 | import org.onosproject.yangutils.utils.io.YangToJavaNamingConflictUtil; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 30 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 31 | import com.google.common.base.MoreObjects; |
| 32 | |
Mahesh Poojary Huawei | 1025a17 | 2016-09-27 16:06:07 +0530 | [diff] [blame^] | 33 | import static org.onosproject.yangutils.utils.UtilConstants.BASE64; |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 34 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype |
| 35 | .YangDataTypes.BINARY; |
Mahesh Poojary Huawei | 1025a17 | 2016-09-27 16:06:07 +0530 | [diff] [blame^] | 36 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.BITS; |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 37 | import static org.onosproject.yangutils.translator.tojava.javamodel |
| 38 | .AttributesJavaDataType.getJavaImportClass; |
| 39 | import static org.onosproject.yangutils.translator.tojava.javamodel |
| 40 | .AttributesJavaDataType.getJavaImportPackage; |
Mahesh Poojary Huawei | 9a16ea0 | 2016-09-02 22:59:00 +0530 | [diff] [blame] | 41 | import static org.onosproject.yangutils.utils.UtilConstants.COLLECTION_IMPORTS; |
Mahesh Poojary Huawei | 1025a17 | 2016-09-27 16:06:07 +0530 | [diff] [blame^] | 42 | import static org.onosproject.yangutils.utils.UtilConstants.REGEX_IMPORTS; |
| 43 | import static org.onosproject.yangutils.utils.UtilConstants.PATTERN; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 44 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 45 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 46 | * Represents the information about individual imports in the generated file. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 47 | */ |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 48 | public class JavaQualifiedTypeInfoTranslator |
| 49 | extends JavaQualifiedTypeInfo |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 50 | implements Comparable<JavaQualifiedTypeInfoTranslator>, Serializable { |
Bharat saraswal | c2d3be1 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 51 | private static final long serialVersionUID = 806201634L; |
| 52 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 53 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 54 | * Creates a java qualified type info object. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 55 | */ |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 56 | public JavaQualifiedTypeInfoTranslator() { |
Bharat saraswal | 2da23bf | 2016-08-25 15:28:39 +0530 | [diff] [blame] | 57 | super(); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 61 | * Returns the imported package info. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 62 | * |
| 63 | * @return the imported package info |
| 64 | */ |
| 65 | public String getPkgInfo() { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 66 | return pkgInfo; |
| 67 | } |
| 68 | |
| 69 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 70 | * Sets the imported package info. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 71 | * |
| 72 | * @param pkgInfo the imported package info |
| 73 | */ |
| 74 | public void setPkgInfo(String pkgInfo) { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 75 | this.pkgInfo = pkgInfo; |
| 76 | } |
| 77 | |
| 78 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 79 | * Returns the imported class/interface info. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 80 | * |
| 81 | * @return the imported class/interface info |
| 82 | */ |
| 83 | public String getClassInfo() { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 84 | return classInfo; |
| 85 | } |
| 86 | |
| 87 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 88 | * Sets the imported class/interface info. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 89 | * |
| 90 | * @param classInfo the imported class/interface info |
| 91 | */ |
| 92 | public void setClassInfo(String classInfo) { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 93 | this.classInfo = classInfo; |
| 94 | } |
| 95 | |
| 96 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 97 | * Updates the leaf's java information. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 98 | * |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 99 | * @param leaf leaf whose java information is being updated |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 100 | */ |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 101 | public static void updateLeavesJavaQualifiedInfo( |
| 102 | JavaLeafInfoContainer leaf) { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 103 | |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 104 | JavaQualifiedTypeInfoTranslator importInfo = |
| 105 | (JavaQualifiedTypeInfoTranslator) leaf.getJavaQualifiedInfo(); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 106 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 107 | if (leaf.getDataType() == null) { |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 108 | throw new TranslatorException( |
| 109 | "missing data type of leaf " + leaf.getName() |
| 110 | + " in " + leaf.getLineNumber() + " at" + |
| 111 | leaf.getCharPosition() + " in " + |
| 112 | leaf.getFileName()); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | /* |
| 116 | * Current leaves holder is adding a leaf info as a attribute to the |
| 117 | * current class. |
| 118 | */ |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 119 | String className = |
| 120 | getJavaImportClass(leaf.getDataType(), leaf.isLeafList(), |
| 121 | leaf.getConflictResolveConfig()); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 122 | if (className != null) { |
| 123 | /* |
| 124 | * Corresponding to the attribute type a class needs to be imported, |
| 125 | * since it can be a derived type or a usage of wrapper classes. |
| 126 | */ |
| 127 | importInfo.setClassInfo(className); |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 128 | String classPkg = getJavaImportPackage(leaf.getDataType(), |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 129 | leaf.isLeafList(), |
| 130 | leaf.getConflictResolveConfig()); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 131 | if (classPkg == null) { |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 132 | throw new TranslatorException( |
| 133 | "import package cannot be null when the class is used" + |
| 134 | " for " |
| 135 | + leaf.getName() |
| 136 | + " in " + leaf.getLineNumber() + " at" + |
| 137 | leaf.getCharPosition() + " in " + |
| 138 | leaf.getFileName()); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 139 | } |
| 140 | importInfo.setPkgInfo(classPkg); |
| 141 | } else { |
| 142 | /* |
| 143 | * The attribute does not need a class to be imported, for example |
| 144 | * built in java types. |
| 145 | */ |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 146 | String dataTypeName = |
| 147 | AttributesJavaDataType.getJavaDataType(leaf.getDataType()); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 148 | if (dataTypeName == null) { |
Bharat saraswal | e3175d3 | 2016-08-31 17:50:11 +0530 | [diff] [blame] | 149 | throw new TranslatorException("not supported data type for " |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 150 | + leaf.getName() |
| 151 | + " in " + |
| 152 | leaf.getLineNumber() + |
| 153 | " at" + |
| 154 | leaf.getCharPosition() + |
| 155 | " in " + |
| 156 | leaf.getFileName()); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 157 | } |
| 158 | importInfo.setClassInfo(dataTypeName); |
| 159 | } |
VinodKumarS-Huawei | 8f16422 | 2016-08-31 15:47:30 +0530 | [diff] [blame] | 160 | |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 161 | leaf.getJavaQualifiedInfo().setJavaAttributeName(leaf.getJavaName( |
| 162 | leaf.getConflictResolveConfig())); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 166 | * Returns the import info for an attribute, which needs to be used for code |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 167 | * generation for import or for qualified access. |
| 168 | * |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 169 | * @param curNode current data model node for which the java file |
| 170 | * is being |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 171 | * generated |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 172 | * @param attributeName name of the attribute being added, it will used in |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 173 | * import info for child class |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 174 | * @return return the import info for this attribute |
| 175 | */ |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 176 | public static JavaQualifiedTypeInfoTranslator getQualifiedTypeInfoOfCurNode( |
| 177 | YangNode curNode, |
| 178 | String attributeName) { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 179 | |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 180 | JavaQualifiedTypeInfoTranslator importInfo = |
| 181 | new JavaQualifiedTypeInfoTranslator(); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 182 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 183 | if (!(curNode instanceof JavaFileInfoContainer)) { |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 184 | throw new TranslatorException( |
| 185 | "missing java file information to get the package details " |
| 186 | + "of attribute corresponding to child node " + |
| 187 | curNode.getName() + |
| 188 | " in " + curNode.getLineNumber() + " at " + |
| 189 | curNode.getCharPosition() + " in " + |
| 190 | curNode.getFileName()); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 191 | } |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 192 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 193 | importInfo.setClassInfo(attributeName); |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 194 | importInfo.setPkgInfo(((JavaFileInfoContainer) curNode) |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 195 | .getJavaFileInfo().getPackage()); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 196 | |
| 197 | return importInfo; |
| 198 | } |
| 199 | |
| 200 | /** |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 201 | * Returns the java qualified type information for the wrapper classes. |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 202 | * |
| 203 | * @param referredTypesAttrInfo attribute of referred type |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 204 | * @param conflictResolver plugin configurations |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 205 | * @return return the import info for this attribute |
| 206 | */ |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 207 | static JavaQualifiedTypeInfoTranslator getQualifiedInfoOfFromString( |
| 208 | JavaAttributeInfo referredTypesAttrInfo, |
| 209 | YangToJavaNamingConflictUtil conflictResolver) { |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 210 | |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 211 | /* |
| 212 | * Get the java qualified type information for the wrapper classes and |
| 213 | * set it in new java attribute information. |
| 214 | */ |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 215 | JavaQualifiedTypeInfoTranslator qualifiedInfoOfFromString = |
| 216 | new JavaQualifiedTypeInfoTranslator(); |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 217 | |
Mahesh Poojary Huawei | 9a16ea0 | 2016-09-02 22:59:00 +0530 | [diff] [blame] | 218 | if (referredTypesAttrInfo.getAttributeType().getDataType() == BINARY) { |
| 219 | qualifiedInfoOfFromString.setClassInfo(BASE64); |
| 220 | qualifiedInfoOfFromString.setPkgInfo(COLLECTION_IMPORTS); |
Mahesh Poojary Huawei | 1025a17 | 2016-09-27 16:06:07 +0530 | [diff] [blame^] | 221 | } else if (referredTypesAttrInfo.getAttributeType().getDataType() == BITS) { |
| 222 | qualifiedInfoOfFromString.setClassInfo(PATTERN); |
| 223 | qualifiedInfoOfFromString.setPkgInfo(REGEX_IMPORTS); |
Mahesh Poojary Huawei | 9a16ea0 | 2016-09-02 22:59:00 +0530 | [diff] [blame] | 224 | } else { |
| 225 | qualifiedInfoOfFromString.setClassInfo( |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 226 | getJavaImportClass(referredTypesAttrInfo.getAttributeType(), |
| 227 | true, conflictResolver)); |
Mahesh Poojary Huawei | 9a16ea0 | 2016-09-02 22:59:00 +0530 | [diff] [blame] | 228 | qualifiedInfoOfFromString.setPkgInfo( |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 229 | getJavaImportPackage( |
| 230 | referredTypesAttrInfo.getAttributeType(), true, |
| 231 | conflictResolver)); |
Mahesh Poojary Huawei | 9a16ea0 | 2016-09-02 22:59:00 +0530 | [diff] [blame] | 232 | } |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 233 | return qualifiedInfoOfFromString; |
| 234 | } |
| 235 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 236 | @Override |
| 237 | public int hashCode() { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 238 | return Objects.hash(pkgInfo, classInfo); |
| 239 | } |
| 240 | |
| 241 | @Override |
| 242 | public boolean equals(Object obj) { |
| 243 | |
| 244 | if (this == obj) { |
| 245 | return true; |
| 246 | } |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 247 | if (obj instanceof JavaQualifiedTypeInfoTranslator) { |
VinodKumarS-Huawei | 3288910 | 2016-09-06 10:54:37 +0530 | [diff] [blame] | 248 | JavaQualifiedTypeInfoTranslator other = |
| 249 | (JavaQualifiedTypeInfoTranslator) obj; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 250 | return Objects.equals(pkgInfo, other.pkgInfo) && |
| 251 | Objects.equals(classInfo, other.classInfo); |
| 252 | } |
| 253 | return false; |
| 254 | } |
| 255 | |
| 256 | /** |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 257 | * Checks if the import info matches. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 258 | * |
| 259 | * @param importInfo matched import |
| 260 | * @return if equal or not |
| 261 | */ |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 262 | public boolean exactMatch(JavaQualifiedTypeInfoTranslator importInfo) { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 263 | return equals(importInfo) |
| 264 | && Objects.equals(pkgInfo, importInfo.getPkgInfo()) |
| 265 | && Objects.equals(classInfo, importInfo.getClassInfo()); |
| 266 | } |
| 267 | |
| 268 | @Override |
| 269 | public String toString() { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 270 | return MoreObjects.toStringHelper(getClass()) |
| 271 | .add("pkgInfo", pkgInfo) |
| 272 | .add("classInfo", classInfo).toString(); |
| 273 | } |
| 274 | |
| 275 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 276 | * Checks that there is no 2 objects with the same class name. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 277 | * |
| 278 | * @param other compared import info. |
| 279 | */ |
| 280 | @Override |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 281 | public int compareTo(JavaQualifiedTypeInfoTranslator other) { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 282 | return getClassInfo().compareTo(other.getClassInfo()); |
| 283 | } |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 284 | } |