Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.yangutils.translator.tojava.utils; |
| 18 | |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 19 | import org.onosproject.yangutils.translator.tojava.AttributeInfo; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 20 | import org.onosproject.yangutils.utils.UtilConstants; |
| 21 | import org.onosproject.yangutils.utils.io.impl.JavaDocGen; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 22 | import org.onosproject.yangutils.utils.io.impl.YangIoUtils; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * Generated methods for generated files based on the file type. |
| 26 | */ |
| 27 | public final class MethodsGenerator { |
| 28 | |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 29 | /** |
| 30 | * Default constructor. |
| 31 | */ |
| 32 | private MethodsGenerator() { |
| 33 | } |
| 34 | |
| 35 | /** |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 36 | * Returns the methods strings for builder interface. |
| 37 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 38 | * @param attr attribute info |
| 39 | * @param className name of the java class being generated |
| 40 | * @return method string for builder interface |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 41 | */ |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 42 | static String parseBuilderInterfaceMethodString(AttributeInfo attr, String className) { |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 43 | |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 44 | return getGetterString(attr) + UtilConstants.NEW_LINE + getSetterString(attr, className); |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Returns the methods strings for builder interface. |
| 49 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 50 | * @param name attribute name |
| 51 | * @return method string for builder interface |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 52 | */ |
| 53 | public static String parseBuilderInterfaceBuildMethodString(String name) { |
| 54 | |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 55 | return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.BUILD, name, false) |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 56 | + getBuildForInterface(name); |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Returns getter string. |
| 61 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 62 | * @param attr attribute info |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 63 | * @return getter string |
| 64 | */ |
| 65 | public static String getGetterString(AttributeInfo attr) { |
| 66 | |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 67 | String returnType = ""; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 68 | boolean isList = attr.isListAttr(); |
| 69 | if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) { |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 70 | returnType = attr.getImportInfo().getPkgInfo() + "."; |
| 71 | } |
| 72 | |
| 73 | returnType = returnType + attr.getImportInfo().getClassInfo(); |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 74 | String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName()); |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 75 | |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 76 | return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.GETTER, attributeName, isList) + |
| 77 | |
| 78 | getGetterForInterface(attributeName, returnType, attr.isListAttr()) |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 79 | + UtilConstants.NEW_LINE; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Returns setter string. |
| 84 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 85 | * @param attr attribute info |
| 86 | * @param className java class name |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 87 | * @return setter string |
| 88 | */ |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 89 | public static String getSetterString(AttributeInfo attr, String className) { |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 90 | |
| 91 | String attrType = ""; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 92 | boolean isList = attr.isListAttr(); |
| 93 | if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) { |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 94 | attrType = attr.getImportInfo().getPkgInfo() + "."; |
| 95 | } |
| 96 | |
| 97 | attrType = attrType + attr.getImportInfo().getClassInfo(); |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 98 | String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName()); |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 99 | |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 100 | return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.SETTER, attributeName, isList) |
| 101 | + getSetterForInterface(attributeName, attrType, className, attr.isListAttr()) |
| 102 | + UtilConstants.NEW_LINE; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | /** |
| 106 | * Returns constructor method string. |
| 107 | * |
| 108 | * @param name class name |
| 109 | * @return constructor string |
| 110 | */ |
| 111 | public static String getConstructorString(String name) { |
| 112 | |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 113 | return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.CONSTRUCTOR, name, false); |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Returns default constructor method string. |
| 118 | * |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 119 | * @param name class name |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 120 | * @param modifierType modifier type |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 121 | * @return default constructor string |
| 122 | */ |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 123 | public static String getDefaultConstructorString(String name, String modifierType) { |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 124 | |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 125 | return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.DEFAULT_CONSTRUCTOR, name, false) |
| 126 | + getDefaultConstructor(name, modifierType); |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Returns default constructor method string. |
| 131 | * |
| 132 | * @param attr attribute info |
| 133 | * @param className class name |
| 134 | * @return default constructor string |
| 135 | */ |
| 136 | public static String getTypeDefConstructor(AttributeInfo attr, String className) { |
| 137 | |
| 138 | String attrQuaifiedType = ""; |
| 139 | if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) { |
| 140 | attrQuaifiedType = attr.getImportInfo().getPkgInfo() + "."; |
| 141 | } |
| 142 | attrQuaifiedType = attrQuaifiedType + attr.getImportInfo().getClassInfo(); |
| 143 | String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName()); |
| 144 | |
| 145 | if (!attr.isListAttr()) { |
| 146 | return getTypeDefConstructorString(attrQuaifiedType, attributeName, className); |
| 147 | } |
| 148 | String listAttr = getListString() + attrQuaifiedType + UtilConstants.DIAMOND_CLOSE_BRACKET; |
| 149 | return getTypeDefConstructorString(listAttr, attributeName, className); |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Returns type def's constructor for attribute. |
| 154 | * |
| 155 | * @param type data type |
| 156 | * @param name attribute name |
| 157 | * @param className class name |
| 158 | * @return setter for type def's attribute |
| 159 | */ |
| 160 | private static String getTypeDefConstructorString(String type, String name, String className) { |
| 161 | |
| 162 | return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE |
| 163 | + className + UtilConstants.OPEN_PARENTHESIS |
| 164 | + type + UtilConstants.SPACE + "value" + UtilConstants.CLOSE_PARENTHESIS |
| 165 | + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE |
| 166 | + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.THIS |
| 167 | + UtilConstants.PERIOD + name + UtilConstants.SPACE + UtilConstants.EQUAL + UtilConstants.SPACE |
| 168 | + "value" + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION |
| 169 | + UtilConstants.CLOSE_CURLY_BRACKET; |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * Returns check not null string. |
| 174 | * |
| 175 | * @param name attribute name |
| 176 | * @return check not null string |
| 177 | */ |
| 178 | public static String getCheckNotNull(String name) { |
| 179 | return UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.CHECK_NOT_NULL_STRING |
| 180 | + UtilConstants.OPEN_PARENTHESIS + name + UtilConstants.COMMA + UtilConstants.SPACE + name |
| 181 | + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | /** |
| 185 | * Returns build method string. |
| 186 | * |
| 187 | * @param name class name |
| 188 | * @return build string |
| 189 | */ |
| 190 | public static String getBuildString(String name) { |
| 191 | |
| 192 | return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.OVERRIDE + UtilConstants.NEW_LINE |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 193 | + getBuild(name); |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | /** |
| 197 | * Returns the getter method strings for class file. |
| 198 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 199 | * @param attr attribute info |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 200 | * @return getter method for class |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 201 | */ |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 202 | public static String getGetterForClass(AttributeInfo attr) { |
| 203 | |
| 204 | String attrQuaifiedType = ""; |
| 205 | if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) { |
| 206 | attrQuaifiedType = attr.getImportInfo().getPkgInfo() + "."; |
| 207 | } |
| 208 | attrQuaifiedType = attrQuaifiedType + attr.getImportInfo().getClassInfo(); |
| 209 | String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName()); |
| 210 | |
| 211 | if (!attr.isListAttr()) { |
| 212 | return getGetter(attrQuaifiedType, attributeName); |
| 213 | } |
| 214 | String listAttr = getListString() + attrQuaifiedType + UtilConstants.DIAMOND_CLOSE_BRACKET; |
| 215 | return getGetter(listAttr, attributeName); |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * Returns getter for attribute. |
| 220 | * |
| 221 | * @param type return type |
| 222 | * @param name attribute name |
| 223 | * @return getter for attribute |
| 224 | */ |
| 225 | private static String getGetter(String type, String name) { |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 226 | |
| 227 | return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 228 | + type + UtilConstants.SPACE + UtilConstants.GET_METHOD_PREFIX |
| 229 | + JavaIdentifierSyntax.getCaptialCase(name) + UtilConstants.OPEN_PARENTHESIS |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 230 | + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET |
| 231 | + UtilConstants.NEW_LINE + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.RETURN |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 232 | + UtilConstants.SPACE + name + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 233 | + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | /** |
| 237 | * Returns the setter method strings for class file. |
| 238 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 239 | * @param attr attribute info |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 240 | * @param className name of the class |
| 241 | * @return setter method for class |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 242 | */ |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 243 | public static String getSetterForClass(AttributeInfo attr, String className) { |
| 244 | |
| 245 | String attrQuaifiedType = ""; |
| 246 | if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) { |
| 247 | attrQuaifiedType = attr.getImportInfo().getPkgInfo() + "."; |
| 248 | } |
| 249 | attrQuaifiedType = attrQuaifiedType + attr.getImportInfo().getClassInfo(); |
| 250 | String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName()); |
| 251 | if (!attr.isListAttr()) { |
| 252 | return getSetter(className, attributeName, attrQuaifiedType); |
| 253 | } |
| 254 | String listAttr = getListString() + attrQuaifiedType + UtilConstants.DIAMOND_CLOSE_BRACKET; |
| 255 | return getSetter(className, attributeName, listAttr); |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * Returns setter for attribute. |
| 260 | * |
| 261 | * @param className class name |
| 262 | * @param name attribute name |
| 263 | * @param type return type |
| 264 | * @return setter for attribute |
| 265 | */ |
| 266 | private static String getSetter(String className, String name, String type) { |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 267 | |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 268 | return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE |
| 269 | + className + UtilConstants.BUILDER + UtilConstants.SPACE + UtilConstants.SET_METHOD_PREFIX |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 270 | + JavaIdentifierSyntax.getCaptialCase(name) + UtilConstants.OPEN_PARENTHESIS |
| 271 | + type + UtilConstants.SPACE + name + UtilConstants.CLOSE_PARENTHESIS |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 272 | + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE |
| 273 | + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.THIS + UtilConstants.PERIOD |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 274 | + name + UtilConstants.SPACE + UtilConstants.EQUAL + UtilConstants.SPACE |
| 275 | + name + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE + UtilConstants.EIGHT_SPACE_INDENTATION |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 276 | + UtilConstants.RETURN + UtilConstants.SPACE + UtilConstants.THIS + UtilConstants.SEMI_COLAN |
| 277 | + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | /** |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 281 | * Returns the setter method strings for class file. |
| 282 | * |
| 283 | * @param attr attribute info |
| 284 | * @return setter method for class |
| 285 | */ |
| 286 | public static String getSetterForTypeDefClass(AttributeInfo attr) { |
| 287 | |
| 288 | String attrQuaifiedType = ""; |
| 289 | if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) { |
| 290 | attrQuaifiedType = attr.getImportInfo().getPkgInfo() + "."; |
| 291 | } |
| 292 | attrQuaifiedType = attrQuaifiedType + attr.getImportInfo().getClassInfo(); |
| 293 | String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName()); |
| 294 | |
| 295 | if (!attr.isListAttr()) { |
| 296 | return getTypeDefSetter(attrQuaifiedType, attributeName); |
| 297 | } |
| 298 | String listAttr = getListString() + attrQuaifiedType + UtilConstants.DIAMOND_CLOSE_BRACKET; |
| 299 | return getTypeDefSetter(listAttr, attributeName); |
| 300 | } |
| 301 | |
| 302 | /** |
| 303 | * Returns type def's setter for attribute. |
| 304 | * |
| 305 | * @param type data type |
| 306 | * @param name attribute name |
| 307 | * @return setter for type def's attribute |
| 308 | */ |
| 309 | private static String getTypeDefSetter(String type, String name) { |
| 310 | |
| 311 | return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE |
| 312 | + UtilConstants.VOID + UtilConstants.SPACE + UtilConstants.SET_METHOD_PREFIX |
| 313 | + JavaIdentifierSyntax.getCaptialCase(name) + UtilConstants.OPEN_PARENTHESIS |
| 314 | + type + UtilConstants.SPACE + "value" + UtilConstants.CLOSE_PARENTHESIS |
| 315 | + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE |
| 316 | + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.THIS + UtilConstants.PERIOD |
| 317 | + name + UtilConstants.SPACE + UtilConstants.EQUAL + UtilConstants.SPACE |
| 318 | + "value" + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION |
| 319 | + UtilConstants.CLOSE_CURLY_BRACKET; |
| 320 | } |
| 321 | |
| 322 | /** |
| 323 | * Returns override string. |
| 324 | * |
| 325 | * @return override string |
| 326 | */ |
| 327 | public static String getOverRideString() { |
| 328 | return UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION |
| 329 | + UtilConstants.OVERRIDE + UtilConstants.NEW_LINE; |
| 330 | } |
| 331 | |
| 332 | /** |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 333 | * Returns the getter method strings for interface file. |
| 334 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 335 | * @param yangName name of the attribute |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 336 | * @param returnType return type of attribute |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 337 | * @param isList is list attribute |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 338 | * @return getter method for interface |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 339 | */ |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 340 | public static String getGetterForInterface(String yangName, String returnType, boolean isList) { |
| 341 | |
| 342 | if (!isList) { |
| 343 | return getGetterInterfaceString(returnType, yangName); |
| 344 | } |
| 345 | String listAttr = getListString() + returnType + UtilConstants.DIAMOND_CLOSE_BRACKET; |
| 346 | return getGetterInterfaceString(listAttr, yangName); |
| 347 | } |
| 348 | |
| 349 | /** |
| 350 | * Returns getter for attribute in interface. |
| 351 | * |
| 352 | * @param returnType return type |
| 353 | * @param yangName attribute name |
| 354 | * @return getter for interface |
| 355 | */ |
| 356 | private static String getGetterInterfaceString(String returnType, String yangName) { |
| 357 | |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 358 | return UtilConstants.FOUR_SPACE_INDENTATION + returnType |
| 359 | + UtilConstants.SPACE + UtilConstants.GET_METHOD_PREFIX |
| 360 | + JavaIdentifierSyntax.getCaptialCase(yangName) |
| 361 | + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS |
| 362 | + UtilConstants.SEMI_COLAN; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 363 | |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | /** |
| 367 | * Returns the setter method strings for interface file. |
| 368 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 369 | * @param attrName name of the attribute |
| 370 | * @param attrType return type of attribute |
| 371 | * @param className name of the java class being generated |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 372 | * @param isList is list attribute |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 373 | * @return setter method for interface |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 374 | */ |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 375 | public static String getSetterForInterface(String attrName, String attrType, String className, boolean isList) { |
| 376 | |
| 377 | if (!isList) { |
| 378 | return getSetterInterfaceString(className, attrName, attrType); |
| 379 | } |
| 380 | String listAttr = getListString() + attrType + UtilConstants.DIAMOND_CLOSE_BRACKET; |
| 381 | return getSetterInterfaceString(className, attrName, listAttr); |
| 382 | } |
| 383 | |
| 384 | /** |
| 385 | * Returns setter string for interface. |
| 386 | * |
| 387 | * @param className class name |
| 388 | * @param attrName attribute name |
| 389 | * @param attrType attribute type |
| 390 | * @return setter string |
| 391 | */ |
| 392 | private static String getSetterInterfaceString(String className, String attrName, String attrType) { |
| 393 | |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 394 | return UtilConstants.FOUR_SPACE_INDENTATION + className + UtilConstants.BUILDER |
| 395 | + UtilConstants.SPACE + UtilConstants.SET_METHOD_PREFIX |
| 396 | + JavaIdentifierSyntax.getCaptialCase(attrName) + UtilConstants.OPEN_PARENTHESIS |
| 397 | + attrType + UtilConstants.SPACE + attrName + UtilConstants.CLOSE_PARENTHESIS |
| 398 | + UtilConstants.SEMI_COLAN; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | /** |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 402 | * Returns list string. |
| 403 | * |
| 404 | * @return list string |
| 405 | */ |
| 406 | private static String getListString() { |
| 407 | return UtilConstants.LIST + UtilConstants.DIAMOND_OPEN_BRACKET; |
| 408 | } |
| 409 | |
| 410 | /** |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 411 | * Returns the build method strings for interface file. |
| 412 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 413 | * @param yangName name of the interface |
| 414 | * @return build method for interface |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 415 | */ |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 416 | public static String getBuildForInterface(String yangName) { |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 417 | |
| 418 | return UtilConstants.FOUR_SPACE_INDENTATION + yangName + UtilConstants.SPACE + UtilConstants.BUILD |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 419 | + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN |
| 420 | + UtilConstants.NEW_LINE; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | /** |
| 424 | * Returns the constructor strings for class file. |
| 425 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 426 | * @param yangName name of the class |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 427 | * @param attr attribute info |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 428 | * @return constructor for class |
| 429 | */ |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 430 | public static String getConstructor(String yangName, AttributeInfo attr) { |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 431 | |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 432 | String builderAttribute = JavaIdentifierSyntax.getLowerCase(yangName); |
| 433 | String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName()); |
| 434 | String constructor = UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.THIS |
| 435 | + UtilConstants.PERIOD + JavaIdentifierSyntax.getCamelCase(attributeName) |
| 436 | + UtilConstants.SPACE + UtilConstants.EQUAL + UtilConstants.SPACE + builderAttribute |
Bharat saraswal | 5600f0f | 2016-03-09 18:34:56 +0530 | [diff] [blame] | 437 | + UtilConstants.BUILDER + UtilConstants.OBJECT + UtilConstants.PERIOD + UtilConstants.GET_METHOD_PREFIX |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 438 | + JavaIdentifierSyntax.getCaptialCase(JavaIdentifierSyntax.getCamelCase(attributeName)) |
| 439 | + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN |
| 440 | + UtilConstants.NEW_LINE; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 441 | |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 442 | return constructor; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | /** |
| 446 | * Returns the build method strings for class file. |
| 447 | * |
| 448 | * @param yangName class name |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 449 | * @return build method string for class |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 450 | */ |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 451 | public static String getBuild(String yangName) { |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 452 | |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 453 | return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE |
| 454 | + yangName + UtilConstants.SPACE + UtilConstants.BUILD + UtilConstants.OPEN_PARENTHESIS |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 455 | + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET |
| 456 | + UtilConstants.NEW_LINE + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.RETURN |
| 457 | + UtilConstants.SPACE + UtilConstants.NEW + UtilConstants.SPACE + yangName + UtilConstants.IMPL |
| 458 | + UtilConstants.OPEN_PARENTHESIS + UtilConstants.THIS + UtilConstants.CLOSE_PARENTHESIS |
| 459 | + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION |
| 460 | + UtilConstants.CLOSE_CURLY_BRACKET; |
| 461 | } |
| 462 | |
| 463 | /** |
| 464 | * Returns the Default constructor strings for class file. |
| 465 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 466 | * @param name name of the class |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 467 | * @param modifierType modifier type for default constructor |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 468 | * @return Default constructor for class |
| 469 | */ |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 470 | private static String getDefaultConstructor(String name, String modifierType) { |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 471 | |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 472 | return UtilConstants.FOUR_SPACE_INDENTATION + modifierType + UtilConstants.SPACE + name |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 473 | + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE |
| 474 | + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION |
| 475 | + UtilConstants.CLOSE_CURLY_BRACKET + UtilConstants.NEW_LINE; |
| 476 | } |
| 477 | |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 478 | /** |
| 479 | * Returns to string method open strings. |
| 480 | * |
| 481 | * @return to string method open string |
| 482 | */ |
| 483 | public static String getToStringMethodOpen() { |
| 484 | |
| 485 | return getOverRideString() + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE |
| 486 | + UtilConstants.STRING + UtilConstants.SPACE + "to" + UtilConstants.STRING |
| 487 | + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE |
| 488 | + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE + UtilConstants.EIGHT_SPACE_INDENTATION |
| 489 | + UtilConstants.RETURN + " MoreObjects.toStringHelper(getClass())" + UtilConstants.NEW_LINE; |
| 490 | } |
| 491 | |
| 492 | /** |
| 493 | * Returns to string methods close string. |
| 494 | * |
| 495 | * @return to string method close string |
| 496 | */ |
| 497 | public static String getToStringMethodClose() { |
| 498 | return UtilConstants.TWELVE_SPACE_INDENTATION + ".to" + UtilConstants.STRING |
| 499 | + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN |
| 500 | + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION |
| 501 | + UtilConstants.CLOSE_CURLY_BRACKET; |
| 502 | } |
| 503 | |
| 504 | /** |
| 505 | * To string method for class. |
| 506 | * |
| 507 | * @param attr attribute info |
| 508 | * @return to string method |
| 509 | */ |
| 510 | public static String getToStringMethod(AttributeInfo attr) { |
| 511 | String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName()); |
| 512 | return UtilConstants.TWELVE_SPACE_INDENTATION + UtilConstants.PERIOD + UtilConstants.ADD_STRING |
| 513 | + UtilConstants.OPEN_PARENTHESIS + UtilConstants.QUOTES |
| 514 | + attributeName + UtilConstants.QUOTES + UtilConstants.COMMA + UtilConstants.SPACE + attributeName |
| 515 | + UtilConstants.CLOSE_PARENTHESIS; |
| 516 | |
| 517 | } |
| 518 | |
| 519 | /** |
| 520 | * Returns to hash code method open strings. |
| 521 | * |
| 522 | * @return to hash code method open string |
| 523 | */ |
| 524 | public static String getHashCodeMethodOpen() { |
| 525 | |
| 526 | return getOverRideString() + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE |
| 527 | + UtilConstants.INT + UtilConstants.SPACE + UtilConstants.HASH_CODE_STRING |
| 528 | + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE |
| 529 | + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE + UtilConstants.EIGHT_SPACE_INDENTATION |
| 530 | + UtilConstants.RETURN + " Objects.hash" + UtilConstants.OPEN_PARENTHESIS; |
| 531 | } |
| 532 | |
| 533 | /** |
| 534 | * Returns to hash code methods close string. |
| 535 | * |
| 536 | * @param hashcodeString hash code string |
| 537 | * @return to hash code method close string |
| 538 | */ |
| 539 | public static String getHashCodeMethodClose(String hashcodeString) { |
| 540 | hashcodeString = YangIoUtils.trimAtLast(hashcodeString, UtilConstants.COMMA); |
| 541 | hashcodeString = YangIoUtils.trimAtLast(hashcodeString, UtilConstants.SPACE); |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 542 | return hashcodeString + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE |
| 543 | + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET; |
| 544 | } |
| 545 | |
| 546 | /** |
| 547 | * Hash code method for class. |
| 548 | * |
| 549 | * @param attr attribute info |
| 550 | * @return hash code method |
| 551 | */ |
| 552 | public static String getHashCodeMethod(AttributeInfo attr) { |
| 553 | String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName()); |
| 554 | return attributeName |
| 555 | + UtilConstants.COMMA + UtilConstants.SPACE; |
| 556 | |
| 557 | } |
| 558 | |
| 559 | /** |
| 560 | * Returns to equals method open strings. |
| 561 | * |
| 562 | * @param className class name |
| 563 | * @return to equals method open string |
| 564 | */ |
| 565 | public static String getEqualsMethodOpen(String className) { |
| 566 | |
| 567 | return getOverRideString() + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE |
| 568 | + UtilConstants.BOOLEAN + UtilConstants.SPACE + UtilConstants.EQUALS_STRING |
| 569 | + UtilConstants.OPEN_PARENTHESIS + UtilConstants.OBJECT_STRING + UtilConstants.SPACE + "obj" |
| 570 | + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET |
| 571 | + UtilConstants.NEW_LINE + getEqualsMethodsCommonIfCondition() |
| 572 | + getEqualsMethodsSpecificIfCondition(className); |
| 573 | } |
| 574 | |
| 575 | /** |
| 576 | * Returns equal methods if condition string. |
| 577 | * |
| 578 | * @return if condition string |
| 579 | */ |
| 580 | private static String getEqualsMethodsCommonIfCondition() { |
| 581 | return UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.IF + UtilConstants.SPACE |
| 582 | + UtilConstants.OPEN_PARENTHESIS + UtilConstants.THIS |
| 583 | + UtilConstants.SPACE + UtilConstants.EQUAL + UtilConstants.EQUAL + UtilConstants.SPACE + "obj" |
| 584 | + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET |
| 585 | + UtilConstants.NEW_LINE + UtilConstants.TWELVE_SPACE_INDENTATION + UtilConstants.RETURN |
| 586 | + UtilConstants.SPACE + UtilConstants.TRUE + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE |
| 587 | + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET + UtilConstants.NEW_LINE; |
| 588 | } |
| 589 | |
| 590 | /** |
| 591 | * Returns if condition for specific class object in equals method. |
| 592 | * |
| 593 | * @param className class name |
| 594 | * @return if condition string |
| 595 | */ |
| 596 | private static String getEqualsMethodsSpecificIfCondition(String className) { |
| 597 | return UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.IF + UtilConstants.SPACE |
| 598 | + UtilConstants.OPEN_PARENTHESIS + "obj" + UtilConstants.INSTANCE_OF + className |
| 599 | + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET |
| 600 | + UtilConstants.NEW_LINE + UtilConstants.TWELVE_SPACE_INDENTATION + className + UtilConstants.SPACE |
| 601 | + "other " + UtilConstants.EQUAL + UtilConstants.SPACE + UtilConstants.OPEN_PARENTHESIS + className |
| 602 | + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE + "obj" + UtilConstants.SEMI_COLAN |
| 603 | + UtilConstants.NEW_LINE + UtilConstants.TWELVE_SPACE_INDENTATION + UtilConstants.RETURN |
| 604 | + UtilConstants.NEW_LINE; |
| 605 | } |
| 606 | |
| 607 | /** |
| 608 | * Returns to equals methods close string. |
| 609 | * |
| 610 | * @param equalMethodString equal method string |
| 611 | * @return to equals method close string |
| 612 | */ |
| 613 | public static String getEqualsMethodClose(String equalMethodString) { |
| 614 | equalMethodString = YangIoUtils.trimAtLast(equalMethodString, UtilConstants.AND); |
| 615 | equalMethodString = YangIoUtils.trimAtLast(equalMethodString, UtilConstants.AND); |
| 616 | equalMethodString = YangIoUtils.trimAtLast(equalMethodString, UtilConstants.SPACE); |
| 617 | equalMethodString = YangIoUtils.trimAtLast(equalMethodString, UtilConstants.NEW_LINE) + UtilConstants.SEMI_COLAN |
| 618 | + UtilConstants.NEW_LINE; |
| 619 | return equalMethodString + UtilConstants.EIGHT_SPACE_INDENTATION |
| 620 | + UtilConstants.CLOSE_CURLY_BRACKET + UtilConstants.NEW_LINE |
| 621 | + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.RETURN + UtilConstants.SPACE |
| 622 | + UtilConstants.FALSE + UtilConstants.SEMI_COLAN |
| 623 | + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION |
| 624 | + UtilConstants.CLOSE_CURLY_BRACKET; |
| 625 | } |
| 626 | |
| 627 | /** |
| 628 | * Equals method for class. |
| 629 | * |
| 630 | * @param attr attribute info |
| 631 | * @return equals method |
| 632 | */ |
| 633 | public static String getEqualsMethod(AttributeInfo attr) { |
| 634 | String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName()); |
| 635 | return UtilConstants.SIXTEEN_SPACE_INDENTATION + UtilConstants.SPACE + UtilConstants.OBJECT_STRING + "s" |
| 636 | + UtilConstants.PERIOD + UtilConstants.EQUALS_STRING + UtilConstants.OPEN_PARENTHESIS + attributeName |
| 637 | + UtilConstants.COMMA + UtilConstants.SPACE + "other." + attributeName + UtilConstants.CLOSE_PARENTHESIS |
| 638 | + UtilConstants.SPACE + UtilConstants.AND + UtilConstants.AND; |
| 639 | |
| 640 | } |
| 641 | |
| 642 | /** |
| 643 | * Returns of method string for class. |
| 644 | * |
| 645 | * @param name class name |
| 646 | * @param attr attribute info |
| 647 | * @return of method string |
| 648 | */ |
| 649 | public static String getOfMethod(String name, AttributeInfo attr) { |
| 650 | |
| 651 | String attrQuaifiedType = ""; |
| 652 | if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) { |
| 653 | attrQuaifiedType = attr.getImportInfo().getPkgInfo() + "."; |
| 654 | } |
| 655 | attrQuaifiedType = attrQuaifiedType + attr.getImportInfo().getClassInfo(); |
| 656 | |
| 657 | return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE + UtilConstants.STATIC |
| 658 | + UtilConstants.SPACE + name + UtilConstants.SPACE + UtilConstants.OF + UtilConstants.OPEN_PARENTHESIS |
| 659 | + attrQuaifiedType + UtilConstants.SPACE + UtilConstants.VALUE + UtilConstants.CLOSE_PARENTHESIS |
| 660 | + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE |
| 661 | + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.RETURN + UtilConstants.SPACE + UtilConstants.NEW |
| 662 | + UtilConstants.SPACE + name + UtilConstants.OPEN_PARENTHESIS + UtilConstants.VALUE |
| 663 | + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE |
| 664 | + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET + UtilConstants.NEW_LINE; |
| 665 | } |
| 666 | |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 667 | } |