Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 0f7908b | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +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.utils; |
| 18 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 19 | import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 20 | |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 21 | import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getParseFromStringMethod; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 22 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; |
| 23 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase; |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 24 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 25 | import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING; |
| 26 | import static org.onosproject.yangutils.utils.UtilConstants.AND; |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 27 | import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTATION; |
| 28 | import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 29 | import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE; |
| 30 | import static org.onosproject.yangutils.utils.UtilConstants.BUILD; |
| 31 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 32 | import static org.onosproject.yangutils.utils.UtilConstants.CATCH; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 33 | import static org.onosproject.yangutils.utils.UtilConstants.CHECK_NOT_NULL_STRING; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 34 | import static org.onosproject.yangutils.utils.UtilConstants.CLEAR; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 35 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; |
| 36 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; |
| 37 | import static org.onosproject.yangutils.utils.UtilConstants.COMMA; |
| 38 | import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_CLOSE_BRACKET; |
| 39 | import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_OPEN_BRACKET; |
| 40 | import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION; |
| 41 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
| 42 | import static org.onosproject.yangutils.utils.UtilConstants.EQUAL; |
| 43 | import static org.onosproject.yangutils.utils.UtilConstants.EQUALS_STRING; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 44 | import static org.onosproject.yangutils.utils.UtilConstants.EXCEPTION; |
| 45 | import static org.onosproject.yangutils.utils.UtilConstants.EXCEPTION_VAR; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 46 | import static org.onosproject.yangutils.utils.UtilConstants.FALSE; |
| 47 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 48 | import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_METHOD_NAME; |
| 49 | import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_PARAM_NAME; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 50 | import static org.onosproject.yangutils.utils.UtilConstants.GET_METHOD_PREFIX; |
| 51 | import static org.onosproject.yangutils.utils.UtilConstants.GOOGLE_MORE_OBJECT_METHOD_STRING; |
| 52 | import static org.onosproject.yangutils.utils.UtilConstants.HASH; |
| 53 | import static org.onosproject.yangutils.utils.UtilConstants.HASH_CODE_STRING; |
| 54 | import static org.onosproject.yangutils.utils.UtilConstants.IF; |
| 55 | import static org.onosproject.yangutils.utils.UtilConstants.IMPL; |
| 56 | import static org.onosproject.yangutils.utils.UtilConstants.INSTANCE_OF; |
| 57 | import static org.onosproject.yangutils.utils.UtilConstants.INT; |
| 58 | import static org.onosproject.yangutils.utils.UtilConstants.LIST; |
| 59 | import static org.onosproject.yangutils.utils.UtilConstants.NEW; |
| 60 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 61 | import static org.onosproject.yangutils.utils.UtilConstants.NULL; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 62 | import static org.onosproject.yangutils.utils.UtilConstants.OBJ; |
| 63 | import static org.onosproject.yangutils.utils.UtilConstants.OBJECT; |
| 64 | import static org.onosproject.yangutils.utils.UtilConstants.OBJECT_STRING; |
| 65 | import static org.onosproject.yangutils.utils.UtilConstants.OF; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 66 | import static org.onosproject.yangutils.utils.UtilConstants.OMIT_NULL_VALUE_STRING; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 67 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET; |
| 68 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS; |
| 69 | import static org.onosproject.yangutils.utils.UtilConstants.OTHER; |
| 70 | import static org.onosproject.yangutils.utils.UtilConstants.OVERRIDE; |
| 71 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
| 72 | import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; |
| 73 | import static org.onosproject.yangutils.utils.UtilConstants.QUOTES; |
| 74 | import static org.onosproject.yangutils.utils.UtilConstants.RETURN; |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 75 | import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 76 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; |
| 77 | import static org.onosproject.yangutils.utils.UtilConstants.SET_METHOD_PREFIX; |
| 78 | import static org.onosproject.yangutils.utils.UtilConstants.SIXTEEN_SPACE_INDENTATION; |
| 79 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; |
| 80 | import static org.onosproject.yangutils.utils.UtilConstants.STATIC; |
| 81 | import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE; |
| 82 | import static org.onosproject.yangutils.utils.UtilConstants.SUFFIX_S; |
| 83 | import static org.onosproject.yangutils.utils.UtilConstants.THIS; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 84 | import static org.onosproject.yangutils.utils.UtilConstants.TMP_VAL; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 85 | import static org.onosproject.yangutils.utils.UtilConstants.TO; |
| 86 | import static org.onosproject.yangutils.utils.UtilConstants.TRUE; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 87 | import static org.onosproject.yangutils.utils.UtilConstants.TRY; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 88 | import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION; |
| 89 | import static org.onosproject.yangutils.utils.UtilConstants.VALUE; |
| 90 | import static org.onosproject.yangutils.utils.UtilConstants.VOID; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 91 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILD_METHOD; |
| 92 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.CONSTRUCTOR; |
| 93 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.DEFAULT_CONSTRUCTOR; |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 94 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.FROM_METHOD; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 95 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 96 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.OF_METHOD; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 97 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SETTER_METHOD; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 98 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR; |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 99 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 100 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 101 | |
| 102 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 103 | * Represents generator for methods of generated files based on the file type. |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 104 | */ |
| 105 | public final class MethodsGenerator { |
| 106 | |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 107 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 108 | * Creates an instance of method generator. |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 109 | */ |
| 110 | private MethodsGenerator() { |
| 111 | } |
| 112 | |
| 113 | /** |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 114 | * Returns the methods strings for builder interface. |
| 115 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 116 | * @param name attribute name |
| 117 | * @return method string for builder interface |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 118 | */ |
| 119 | public static String parseBuilderInterfaceBuildMethodString(String name) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 120 | return getJavaDoc(BUILD_METHOD, name, false) + getBuildForInterface(name); |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | /** |
| 124 | * Returns getter string. |
| 125 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 126 | * @param attr attribute info |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 127 | * @return getter string |
| 128 | */ |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 129 | public static String getGetterString(JavaAttributeInfo attr) { |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 130 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 131 | String returnType = getReturnType(attr); |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 132 | String attributeName = getSmallCase(attr.getAttributeName()); |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 133 | |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 134 | return getJavaDoc(GETTER_METHOD, attributeName, attr.isListAttr()) |
| 135 | + getGetterForInterface(attributeName, returnType, attr.isListAttr()); |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Returns setter string. |
| 140 | * |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 141 | * @param attr attribute info |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 142 | * @param className java class name |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 143 | * @return setter string |
| 144 | */ |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 145 | public static String getSetterString(JavaAttributeInfo attr, String className) { |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 146 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 147 | String attrType = getReturnType(attr); |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 148 | String attributeName = getSmallCase(attr.getAttributeName()); |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 149 | |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 150 | return getJavaDoc(SETTER_METHOD, attributeName, attr.isListAttr()) |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 151 | + getSetterForInterface(attributeName, attrType, className, attr.isListAttr()); |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | /** |
| 155 | * Returns constructor method string. |
| 156 | * |
| 157 | * @param name class name |
| 158 | * @return constructor string |
| 159 | */ |
| 160 | public static String getConstructorString(String name) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 161 | return getJavaDoc(CONSTRUCTOR, name, false); |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | /** |
| 165 | * Returns default constructor method string. |
| 166 | * |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 167 | * @param name class name |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 168 | * @param modifierType modifier type |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 169 | * @return default constructor string |
| 170 | */ |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 171 | public static String getDefaultConstructorString(String name, String modifierType) { |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 172 | return getJavaDoc(DEFAULT_CONSTRUCTOR, name, false) + getDefaultConstructor(name, modifierType) |
| 173 | + NEW_LINE; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | /** |
| 177 | * Returns check not null string. |
| 178 | * |
| 179 | * @param name attribute name |
| 180 | * @return check not null string |
| 181 | */ |
| 182 | public static String getCheckNotNull(String name) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 183 | return EIGHT_SPACE_INDENTATION + CHECK_NOT_NULL_STRING + OPEN_PARENTHESIS + name + COMMA + SPACE + name |
| 184 | + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | /** |
| 188 | * Returns build method string. |
| 189 | * |
| 190 | * @param name class name |
| 191 | * @return build string |
| 192 | */ |
| 193 | public static String getBuildString(String name) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 194 | return FOUR_SPACE_INDENTATION + OVERRIDE + NEW_LINE + getBuild(name); |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | /** |
| 198 | * Returns the getter method strings for class file. |
| 199 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 200 | * @param attr attribute info |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 201 | * @return getter method for class |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 202 | */ |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 203 | public static String getGetterForClass(JavaAttributeInfo attr) { |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 204 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 205 | String attrQuaifiedType = getReturnType(attr); |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 206 | String attributeName = getSmallCase(attr.getAttributeName()); |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 207 | |
| 208 | if (!attr.isListAttr()) { |
| 209 | return getGetter(attrQuaifiedType, attributeName); |
| 210 | } |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 211 | String listAttr = getListString() + attrQuaifiedType + DIAMOND_CLOSE_BRACKET; |
| 212 | return getGetter(listAttr, attributeName); |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | /** |
| 216 | * Returns getter for attribute. |
| 217 | * |
| 218 | * @param type return type |
| 219 | * @param name attribute name |
| 220 | * @return getter for attribute |
| 221 | */ |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 222 | public static String getGetter(String type, String name) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 223 | return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + type + SPACE + GET_METHOD_PREFIX + getCaptialCase(name) |
| 224 | + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION |
| 225 | + RETURN + SPACE + name + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | /** |
| 229 | * Returns the setter method strings for class file. |
| 230 | * |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 231 | * @param attr attribute info |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 232 | * @param className name of the class |
| 233 | * @return setter method for class |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 234 | */ |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 235 | public static String getSetterForClass(JavaAttributeInfo attr, String className) { |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 236 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 237 | String attrQuaifiedType = getReturnType(attr); |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 238 | String attributeName = getSmallCase(attr.getAttributeName()); |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 239 | if (!attr.isListAttr()) { |
| 240 | return getSetter(className, attributeName, attrQuaifiedType); |
| 241 | } |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 242 | String listAttr = getListString() + attrQuaifiedType + DIAMOND_CLOSE_BRACKET; |
| 243 | return getSetter(className, attributeName, listAttr); |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | /** |
| 247 | * Returns setter for attribute. |
| 248 | * |
| 249 | * @param className class name |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 250 | * @param name attribute name |
| 251 | * @param type return type |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 252 | * @return setter for attribute |
| 253 | */ |
| 254 | private static String getSetter(String className, String name, String type) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 255 | return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + className + BUILDER + SPACE + SET_METHOD_PREFIX |
| 256 | + getCaptialCase(name) + OPEN_PARENTHESIS + type + SPACE + name + CLOSE_PARENTHESIS + SPACE |
| 257 | + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + THIS + PERIOD + name + SPACE + EQUAL + SPACE |
| 258 | + name + SEMI_COLAN + NEW_LINE + EIGHT_SPACE_INDENTATION + RETURN + SPACE + THIS + SEMI_COLAN |
| 259 | + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | /** |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 263 | * Returns the setter method strings for class file. |
| 264 | * |
| 265 | * @param attr attribute info |
| 266 | * @return setter method for class |
| 267 | */ |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 268 | public static String getSetterForTypeDefClass(JavaAttributeInfo attr) { |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 269 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 270 | String attrQuaifiedType = getReturnType(attr); |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 271 | String attributeName = getSmallCase(attr.getAttributeName()); |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 272 | return getTypeDefSetter(attrQuaifiedType, attributeName); |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | /** |
| 276 | * Returns type def's setter for attribute. |
| 277 | * |
| 278 | * @param type data type |
| 279 | * @param name attribute name |
| 280 | * @return setter for type def's attribute |
| 281 | */ |
| 282 | private static String getTypeDefSetter(String type, String name) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 283 | return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + SET_METHOD_PREFIX + getCaptialCase(name) |
| 284 | + OPEN_PARENTHESIS + type + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE |
| 285 | + EIGHT_SPACE_INDENTATION + THIS + PERIOD + name + SPACE + EQUAL + SPACE + VALUE + SEMI_COLAN + NEW_LINE |
| 286 | + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | /** |
| 290 | * Returns override string. |
| 291 | * |
| 292 | * @return override string |
| 293 | */ |
| 294 | public static String getOverRideString() { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 295 | return NEW_LINE + FOUR_SPACE_INDENTATION + OVERRIDE + NEW_LINE; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | /** |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 299 | * Returns the getter method strings for interface file. |
| 300 | * |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 301 | * @param yangName name of the attribute |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 302 | * @param returnType return type of attribute |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 303 | * @param isList is list attribute |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 304 | * @return getter method for interface |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 305 | */ |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 306 | public static String getGetterForInterface(String yangName, String returnType, boolean isList) { |
| 307 | |
| 308 | if (!isList) { |
| 309 | return getGetterInterfaceString(returnType, yangName); |
| 310 | } |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 311 | String listAttr = getListString() + returnType + DIAMOND_CLOSE_BRACKET; |
| 312 | return getGetterInterfaceString(listAttr, yangName); |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | /** |
| 316 | * Returns getter for attribute in interface. |
| 317 | * |
| 318 | * @param returnType return type |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 319 | * @param yangName attribute name |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 320 | * @return getter for interface |
| 321 | */ |
| 322 | private static String getGetterInterfaceString(String returnType, String yangName) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 323 | return FOUR_SPACE_INDENTATION + returnType + SPACE + GET_METHOD_PREFIX + getCaptialCase(yangName) |
| 324 | + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | /** |
| 328 | * Returns the setter method strings for interface file. |
| 329 | * |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 330 | * @param attrName name of the attribute |
| 331 | * @param attrType return type of attribute |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 332 | * @param className name of the java class being generated |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 333 | * @param isList is list attribute |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 334 | * @return setter method for interface |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 335 | */ |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 336 | public static String getSetterForInterface(String attrName, String attrType, String className, boolean isList) { |
| 337 | |
| 338 | if (!isList) { |
| 339 | return getSetterInterfaceString(className, attrName, attrType); |
| 340 | } |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 341 | String listAttr = getListString() + attrType + DIAMOND_CLOSE_BRACKET; |
| 342 | return getSetterInterfaceString(className, attrName, listAttr); |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | /** |
| 346 | * Returns setter string for interface. |
| 347 | * |
| 348 | * @param className class name |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 349 | * @param attrName attribute name |
| 350 | * @param attrType attribute type |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 351 | * @return setter string |
| 352 | */ |
| 353 | private static String getSetterInterfaceString(String className, String attrName, String attrType) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 354 | return FOUR_SPACE_INDENTATION + className + BUILDER + SPACE + SET_METHOD_PREFIX + getCaptialCase(attrName) |
| 355 | + OPEN_PARENTHESIS + attrType + SPACE + attrName + CLOSE_PARENTHESIS + SEMI_COLAN; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 356 | } |
| 357 | |
| 358 | /** |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 359 | * Returns list string. |
| 360 | * |
| 361 | * @return list string |
| 362 | */ |
| 363 | private static String getListString() { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 364 | return LIST + DIAMOND_OPEN_BRACKET; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | /** |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 368 | * Returns return type for attribute. |
| 369 | * |
| 370 | * @param attr attribute info |
| 371 | * @return return type |
| 372 | */ |
| 373 | private static String getReturnType(JavaAttributeInfo attr) { |
| 374 | |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 375 | String returnType = EMPTY_STRING; |
Vidyashree Rama | 1396065 | 2016-04-26 15:06:06 +0530 | [diff] [blame] | 376 | if (attr.isQualifiedName() && attr.getImportInfo().getPkgInfo() != null) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 377 | returnType = attr.getImportInfo().getPkgInfo() + PERIOD; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 378 | } |
| 379 | returnType = returnType + attr.getImportInfo().getClassInfo(); |
| 380 | return returnType; |
| 381 | } |
| 382 | |
| 383 | /** |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 384 | * Returns the build method strings for interface file. |
| 385 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 386 | * @param yangName name of the interface |
| 387 | * @return build method for interface |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 388 | */ |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 389 | public static String getBuildForInterface(String yangName) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 390 | return FOUR_SPACE_INDENTATION + yangName + SPACE + BUILD + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN |
| 391 | + NEW_LINE; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 392 | } |
| 393 | |
| 394 | /** |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 395 | * Returns constructor string for impl class. |
| 396 | * |
| 397 | * @param yangName class name |
| 398 | * @return constructor string |
| 399 | */ |
| 400 | public static String getConstructorStart(String yangName) { |
| 401 | |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 402 | String javadoc = getConstructorString(yangName); |
| 403 | String constructor = FOUR_SPACE_INDENTATION + PUBLIC + SPACE + yangName + IMPL + OPEN_PARENTHESIS + yangName |
| 404 | + BUILDER + SPACE + BUILDER.toLowerCase() + OBJECT + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET |
| 405 | + NEW_LINE; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 406 | return javadoc + constructor; |
| 407 | } |
| 408 | |
| 409 | /** |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 410 | * Returns the constructor strings for class file. |
| 411 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 412 | * @param yangName name of the class |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 413 | * @param attr attribute info |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 414 | * @return constructor for class |
| 415 | */ |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 416 | public static String getConstructor(String yangName, JavaAttributeInfo attr) { |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 417 | |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 418 | String attributeName = getSmallCase(attr.getAttributeName()); |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 419 | |
janani b | 1c6acc4 | 2016-04-15 16:18:30 +0530 | [diff] [blame] | 420 | String constructor = EIGHT_SPACE_INDENTATION + THIS + PERIOD + getCamelCase(attributeName, null) + SPACE + EQUAL |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 421 | + SPACE + BUILDER.toLowerCase() + OBJECT + PERIOD + GET_METHOD_PREFIX |
janani b | 1c6acc4 | 2016-04-15 16:18:30 +0530 | [diff] [blame] | 422 | + getCaptialCase(getCamelCase(attributeName, null)) + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 423 | + NEW_LINE; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 424 | |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 425 | return constructor; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | /** |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 429 | * Returns the rpc strings for service interface. |
| 430 | * |
| 431 | * @param rpcName name of the rpc |
| 432 | * @param inputName name of input |
| 433 | * @param outputName name of output |
| 434 | * @return rpc method string |
| 435 | */ |
| 436 | public static String getRpcStringMethod(String rpcName, String inputName, String outputName) { |
| 437 | |
| 438 | rpcName = getSmallCase(getCamelCase(rpcName, null)); |
| 439 | inputName = getCaptialCase(inputName); |
| 440 | outputName = getCaptialCase(outputName); |
| 441 | |
| 442 | return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + outputName + SPACE + rpcName + OPEN_PARENTHESIS |
| 443 | + inputName + SPACE + RPC_INPUT_VAR_NAME + CLOSE_PARENTHESIS + SEMI_COLAN; |
| 444 | } |
| 445 | |
| 446 | /** |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 447 | * Returns the build method strings for class file. |
| 448 | * |
| 449 | * @param yangName class name |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 450 | * @return build method string for class |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 451 | */ |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 452 | public static String getBuild(String yangName) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 453 | return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + yangName + SPACE + BUILD + OPEN_PARENTHESIS + CLOSE_PARENTHESIS |
| 454 | + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + RETURN + SPACE + NEW + SPACE |
| 455 | + yangName + IMPL + OPEN_PARENTHESIS + THIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE |
| 456 | + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | /** |
| 460 | * Returns the Default constructor strings for class file. |
| 461 | * |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 462 | * @param name name of the class |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 463 | * @param modifierType modifier type for default constructor |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 464 | * @return Default constructor for class |
| 465 | */ |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 466 | private static String getDefaultConstructor(String name, String modifierType) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 467 | return FOUR_SPACE_INDENTATION + modifierType + SPACE + name + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE |
| 468 | + OPEN_CURLY_BRACKET + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 469 | } |
| 470 | |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 471 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 472 | * Returns to string method's open strings. |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 473 | * |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 474 | * @return string method's open string |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 475 | */ |
| 476 | public static String getToStringMethodOpen() { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 477 | return getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + STRING_DATA_TYPE + SPACE + TO |
| 478 | + STRING_DATA_TYPE + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE |
| 479 | + EIGHT_SPACE_INDENTATION + RETURN + GOOGLE_MORE_OBJECT_METHOD_STRING + NEW_LINE; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 483 | * Returns omit null value string. |
| 484 | * |
| 485 | * @return omit null value string |
| 486 | */ |
| 487 | public static String getOmitNullValueString() { |
| 488 | return TWELVE_SPACE_INDENTATION + PERIOD + OMIT_NULL_VALUE_STRING + NEW_LINE; |
| 489 | } |
| 490 | |
| 491 | /** |
| 492 | * Returns to string method's close string. |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 493 | * |
| 494 | * @return to string method close string |
| 495 | */ |
| 496 | public static String getToStringMethodClose() { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 497 | return TWELVE_SPACE_INDENTATION + PERIOD + TO + STRING_DATA_TYPE + OPEN_PARENTHESIS + CLOSE_PARENTHESIS |
| 498 | + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 502 | * Returns to string method for class. |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 503 | * |
| 504 | * @param attr attribute info |
| 505 | * @return to string method |
| 506 | */ |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 507 | public static String getToStringMethod(JavaAttributeInfo attr) { |
| 508 | |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 509 | String attributeName = getSmallCase(attr.getAttributeName()); |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 510 | return TWELVE_SPACE_INDENTATION + PERIOD + ADD_STRING + OPEN_PARENTHESIS + QUOTES + attributeName + QUOTES |
| 511 | + COMMA + SPACE + attributeName + CLOSE_PARENTHESIS; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 515 | * Returns from string method's open string. |
| 516 | * |
| 517 | * @param className name of the class |
| 518 | * @return from string method's open string |
| 519 | */ |
| 520 | public static String getFromStringMethodSignature(String className) { |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 521 | return getJavaDoc(FROM_METHOD, className, false) + FOUR_SPACE_INDENTATION + PUBLIC + SPACE |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 522 | + className + SPACE + FROM_STRING_METHOD_NAME + OPEN_PARENTHESIS + STRING_DATA_TYPE + SPACE |
| 523 | + FROM_STRING_PARAM_NAME + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; |
| 524 | } |
| 525 | |
| 526 | /** |
| 527 | * Return from string method's close string. |
| 528 | * |
| 529 | * @return from string method's close string |
| 530 | */ |
| 531 | public static String getFromStringMethodClose() { |
| 532 | return EIGHT_SPACE_INDENTATION + RETURN + SPACE + NULL + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + |
| 533 | CLOSE_CURLY_BRACKET + NEW_LINE; |
| 534 | } |
| 535 | |
| 536 | /** |
| 537 | * Return from string method's body string. |
| 538 | * |
| 539 | * @param attr attribute info |
| 540 | * @param fromStringAttributeInfo attribute info for the from string |
| 541 | * wrapper type |
| 542 | * @return from string method's body string |
| 543 | */ |
| 544 | public static String getFromStringMethod(JavaAttributeInfo attr, |
| 545 | JavaAttributeInfo fromStringAttributeInfo) { |
| 546 | |
| 547 | return EIGHT_SPACE_INDENTATION + getTrySubString() + NEW_LINE + TWELVE_SPACE_INDENTATION |
| 548 | + getParsedSubString(attr, fromStringAttributeInfo) + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION |
| 549 | + getReturnOfSubString() + NEW_LINE + EIGHT_SPACE_INDENTATION + getCatchSubString() |
| 550 | + NEW_LINE + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; |
| 551 | } |
| 552 | |
| 553 | /** |
| 554 | * Returns sub string with try statement for union's from string method. |
| 555 | * |
| 556 | * @return sub string with try statement for union's from string method |
| 557 | */ |
| 558 | public static String getTrySubString() { |
| 559 | return TRY + SPACE + OPEN_CURLY_BRACKET; |
| 560 | } |
| 561 | |
| 562 | /** |
| 563 | * Returns sub string with return statement for union's from string method. |
| 564 | * |
| 565 | * @return sub string with return statement for union's from string method |
| 566 | */ |
| 567 | public static String getReturnOfSubString() { |
| 568 | return RETURN + SPACE + OF + OPEN_PARENTHESIS + TMP_VAL + CLOSE_PARENTHESIS + SEMI_COLAN; |
| 569 | } |
| 570 | |
| 571 | /** |
| 572 | * Returns sub string with catch statement for union's from string method. |
| 573 | * |
| 574 | * @return sub string with catch statement for union's from string method |
| 575 | */ |
| 576 | public static String getCatchSubString() { |
| 577 | return CLOSE_CURLY_BRACKET + SPACE + CATCH + SPACE + OPEN_PARENTHESIS + EXCEPTION + SPACE + EXCEPTION_VAR |
| 578 | + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET; |
| 579 | } |
| 580 | |
| 581 | /** |
| 582 | * Returns sub string with parsed statement for union's from string method. |
| 583 | * |
| 584 | * @param attr attribute info |
| 585 | * @return sub string with parsed statement for union's from string method |
| 586 | */ |
| 587 | private static String getParsedSubString(JavaAttributeInfo attr, |
| 588 | JavaAttributeInfo fromStringAttributeInfo) { |
| 589 | |
| 590 | String targetDataType = getReturnType(attr); |
| 591 | String parseFromStringMethod = getParseFromStringMethod(targetDataType, |
| 592 | fromStringAttributeInfo.getAttributeType()); |
| 593 | return targetDataType + SPACE + TMP_VAL + SPACE + EQUAL + SPACE + parseFromStringMethod |
| 594 | + OPEN_PARENTHESIS + FROM_STRING_PARAM_NAME + CLOSE_PARENTHESIS; |
| 595 | } |
| 596 | |
| 597 | |
| 598 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 599 | * Returns hash code method open strings. |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 600 | * |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 601 | * @return hash code method open string |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 602 | */ |
| 603 | public static String getHashCodeMethodOpen() { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 604 | return getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + INT + SPACE + HASH_CODE_STRING |
| 605 | + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION |
| 606 | + RETURN + SPACE + OBJECT_STRING + SUFFIX_S + PERIOD + HASH + OPEN_PARENTHESIS; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 607 | } |
| 608 | |
| 609 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 610 | * Returns hash code methods close string. |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 611 | * |
| 612 | * @param hashcodeString hash code string |
| 613 | * @return to hash code method close string |
| 614 | */ |
| 615 | public static String getHashCodeMethodClose(String hashcodeString) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 616 | hashcodeString = trimAtLast(hashcodeString, COMMA); |
| 617 | hashcodeString = trimAtLast(hashcodeString, SPACE); |
| 618 | return hashcodeString + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET |
| 619 | + NEW_LINE; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 620 | } |
| 621 | |
| 622 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 623 | * Returns hash code method for class. |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 624 | * |
| 625 | * @param attr attribute info |
| 626 | * @return hash code method |
| 627 | */ |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 628 | public static String getHashCodeMethod(JavaAttributeInfo attr) { |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 629 | return getSmallCase(attr.getAttributeName()) + COMMA + SPACE; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 630 | } |
| 631 | |
| 632 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 633 | * Returns equals method open strings. |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 634 | * |
| 635 | * @param className class name |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 636 | * @return equals method open string |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 637 | */ |
| 638 | public static String getEqualsMethodOpen(String className) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 639 | return getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BOOLEAN_DATA_TYPE + SPACE + EQUALS_STRING |
| 640 | + OPEN_PARENTHESIS + OBJECT_STRING + SPACE + OBJ + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET |
| 641 | + NEW_LINE + getEqualsMethodsCommonIfCondition() + getEqualsMethodsSpecificIfCondition(className); |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | /** |
| 645 | * Returns equal methods if condition string. |
| 646 | * |
| 647 | * @return if condition string |
| 648 | */ |
| 649 | private static String getEqualsMethodsCommonIfCondition() { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 650 | return EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + THIS + SPACE + EQUAL + EQUAL + SPACE + OBJ |
| 651 | + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + TWELVE_SPACE_INDENTATION + RETURN + SPACE |
| 652 | + TRUE + SEMI_COLAN + NEW_LINE + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | /** |
| 656 | * Returns if condition for specific class object in equals method. |
| 657 | * |
| 658 | * @param className class name |
| 659 | * @return if condition string |
| 660 | */ |
| 661 | private static String getEqualsMethodsSpecificIfCondition(String className) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 662 | return EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + OBJ + INSTANCE_OF + className |
| 663 | + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + TWELVE_SPACE_INDENTATION + className |
| 664 | + SPACE + OTHER + SPACE + EQUAL + SPACE + OPEN_PARENTHESIS + className + CLOSE_PARENTHESIS + SPACE |
| 665 | + OBJ + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION + RETURN + NEW_LINE; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 666 | } |
| 667 | |
| 668 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 669 | * Returns equals methods close string. |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 670 | * |
| 671 | * @param equalMethodString equal method string |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 672 | * @return equals method close string |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 673 | */ |
| 674 | public static String getEqualsMethodClose(String equalMethodString) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 675 | equalMethodString = trimAtLast(equalMethodString, AND); |
| 676 | equalMethodString = trimAtLast(equalMethodString, AND); |
| 677 | equalMethodString = trimAtLast(equalMethodString, SPACE); |
| 678 | equalMethodString = trimAtLast(equalMethodString, NEW_LINE) + SEMI_COLAN + NEW_LINE; |
| 679 | return equalMethodString + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION |
| 680 | + RETURN + SPACE + FALSE + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET |
| 681 | + NEW_LINE; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 682 | } |
| 683 | |
| 684 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 685 | * Returns equals method for class. |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 686 | * |
| 687 | * @param attr attribute info |
| 688 | * @return equals method |
| 689 | */ |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 690 | public static String getEqualsMethod(JavaAttributeInfo attr) { |
| 691 | |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 692 | String attributeName = getSmallCase(attr.getAttributeName()); |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 693 | return SIXTEEN_SPACE_INDENTATION + SPACE + OBJECT_STRING + SUFFIX_S + PERIOD + EQUALS_STRING + OPEN_PARENTHESIS |
| 694 | + attributeName + COMMA + SPACE + OTHER + PERIOD + attributeName + CLOSE_PARENTHESIS + SPACE + AND |
| 695 | + AND; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 696 | } |
| 697 | |
| 698 | /** |
| 699 | * Returns of method string for class. |
| 700 | * |
| 701 | * @param name class name |
| 702 | * @param attr attribute info |
| 703 | * @return of method string |
| 704 | */ |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 705 | public static String getOfMethod(String name, JavaAttributeInfo attr) { |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 706 | |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 707 | String attrQualifiedType = getReturnType(attr); |
| 708 | |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 709 | return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + STATIC + SPACE + name + SPACE + OF + OPEN_PARENTHESIS |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 710 | + attrQualifiedType + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 711 | + EIGHT_SPACE_INDENTATION + RETURN + SPACE + NEW + SPACE + name + OPEN_PARENTHESIS + VALUE |
| 712 | + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 713 | } |
| 714 | |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 715 | /** |
| 716 | * Returns implementation of add augmentation method of HasAugmentation class. |
| 717 | * |
| 718 | * @return implementation of add augmentation method of HasAugmentation class |
| 719 | */ |
| 720 | public static String getAddAugmentInfoMethodImpl() { |
| 721 | String method = FOUR_SPACE_INDENTATION; |
| 722 | method = method + getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + ADD_STRING |
| 723 | + AUGMENTATION + OPEN_PARENTHESIS + AUGMENTED_INFO + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE |
| 724 | + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + GET_METHOD_PREFIX + AUGMENTED_INFO + LIST |
| 725 | + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + ADD_STRING + OPEN_PARENTHESIS + VALUE |
| 726 | + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; |
| 727 | |
| 728 | return method; |
| 729 | } |
| 730 | |
| 731 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 732 | * Returns of method's string and java doc for special type. |
| 733 | * |
| 734 | * @param attr attribute info |
| 735 | * @param generatedJavaClassName class name |
| 736 | * @return of method's string and java doc for special type |
| 737 | */ |
| 738 | public static String getOfMethodStringAndJavaDoc(JavaAttributeInfo attr, String generatedJavaClassName) { |
| 739 | |
| 740 | String attrType = getReturnType(attr); |
| 741 | String attrName = getSmallCase(attr.getAttributeName()); |
| 742 | |
| 743 | return getJavaDoc(OF_METHOD, generatedJavaClassName + " for type " + attrName, false) |
| 744 | + getOfMethodString(attrType, generatedJavaClassName); |
| 745 | } |
| 746 | |
| 747 | /** |
| 748 | * Returns of method's string. |
| 749 | * |
| 750 | * @param type data type |
| 751 | * @param className class name |
| 752 | * @return of method's string |
| 753 | */ |
| 754 | private static String getOfMethodString(String type, String className) { |
| 755 | |
| 756 | return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + STATIC + SPACE + className + SPACE + OF + OPEN_PARENTHESIS |
| 757 | + type + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE |
| 758 | + EIGHT_SPACE_INDENTATION + RETURN + SPACE + NEW + SPACE + className + OPEN_PARENTHESIS + VALUE |
| 759 | + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; |
| 760 | } |
| 761 | |
| 762 | /** |
| 763 | * Returns string and java doc for constructor of type class. |
| 764 | * |
| 765 | * @param attr attribute info |
| 766 | * @param generatedJavaClassName class name |
| 767 | * @return string and java doc for constructor of type class |
| 768 | */ |
| 769 | public static String getTypeConstructorStringAndJavaDoc(JavaAttributeInfo attr, String generatedJavaClassName) { |
| 770 | |
| 771 | String attrType = getReturnType(attr); |
| 772 | String attrName = getSmallCase(attr.getAttributeName()); |
| 773 | |
| 774 | return getJavaDoc(TYPE_CONSTRUCTOR, generatedJavaClassName + " for type " + attrName, false) |
| 775 | + getTypeConstructorString(attrType, attrName, generatedJavaClassName); |
| 776 | } |
| 777 | |
| 778 | /** |
| 779 | * Returns type constructor string. |
| 780 | * |
| 781 | * @param type data type |
| 782 | * @param name attribute name |
| 783 | * @param className class name |
| 784 | * @return type constructor string |
| 785 | */ |
| 786 | private static String getTypeConstructorString(String type, String name, String className) { |
| 787 | |
| 788 | return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + className + OPEN_PARENTHESIS + type + SPACE + VALUE |
| 789 | + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + THIS + PERIOD |
| 790 | + name + SPACE + EQUAL + SPACE + VALUE + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION |
| 791 | + CLOSE_CURLY_BRACKET; |
| 792 | } |
| 793 | |
| 794 | /** |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 795 | * Returns implementation of get augment info list method of HasAugmentation class. |
| 796 | * |
| 797 | * @return implementation of get augment info list method of HasAugmentation class |
| 798 | */ |
| 799 | public static String getAugmentInfoListImpl() { |
| 800 | |
| 801 | String method = FOUR_SPACE_INDENTATION; |
| 802 | method = method + getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + LIST + DIAMOND_OPEN_BRACKET |
| 803 | + AUGMENTED_INFO + DIAMOND_CLOSE_BRACKET + SPACE + GET_METHOD_PREFIX + AUGMENTED_INFO + LIST |
| 804 | + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION |
| 805 | + RETURN + SPACE + getSmallCase(AUGMENTED_INFO) + LIST + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION |
| 806 | + CLOSE_CURLY_BRACKET; |
| 807 | return method; |
| 808 | } |
| 809 | |
| 810 | /** |
| 811 | * Returns implementation of remove augmentation method of HasAugmentation class. |
| 812 | * |
| 813 | * @return implementation of remove augmentation method of HasAugmentation class |
| 814 | */ |
| 815 | public static String getRemoveAugmentationImpl() { |
| 816 | String method = FOUR_SPACE_INDENTATION; |
| 817 | method = method + getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + "remove" |
| 818 | + AUGMENTATION + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE |
| 819 | + EIGHT_SPACE_INDENTATION + GET_METHOD_PREFIX + AUGMENTED_INFO + LIST + OPEN_PARENTHESIS |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 820 | + CLOSE_PARENTHESIS + PERIOD + CLEAR + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 821 | + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; |
| 822 | return method; |
| 823 | } |
| 824 | |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 825 | /** |
| 826 | * Returns enum's constructor. |
| 827 | * |
| 828 | * @param className enum's class name |
| 829 | * @return enum's constructor |
| 830 | */ |
| 831 | public static String getEnumsConstrcutor(String className) { |
| 832 | return FOUR_SPACE_INDENTATION + className + OPEN_PARENTHESIS + INT + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE |
| 833 | + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + getSmallCase(className) + SPACE + EQUAL |
| 834 | + SPACE + VALUE + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; |
| 835 | } |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 836 | } |