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.utils.io.impl; |
| 18 | |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 19 | import org.onosproject.yangutils.utils.io.YangPluginConfig; |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 20 | |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 21 | import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 22 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; |
| 23 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_CLASS_JAVA_DOC; |
| 24 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_INTERFACE_JAVA_DOC; |
| 25 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_OBJECT; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 26 | import static org.onosproject.yangutils.utils.UtilConstants.CLASS; |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 27 | import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION; |
Bharat saraswal | 5cd9e9c | 2016-05-26 23:48:38 +0530 | [diff] [blame] | 28 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 29 | import static org.onosproject.yangutils.utils.UtilConstants.ENUM_ATTRIBUTE_JAVADOC; |
| 30 | import static org.onosproject.yangutils.utils.UtilConstants.ENUM_CLASS_JAVADOC; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 31 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_JAVA_DOC; |
| 32 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER_JAVA_DOC; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 33 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 34 | import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_METHOD_NAME; |
| 35 | import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_PARAM_NAME; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 36 | import static org.onosproject.yangutils.utils.UtilConstants.IMPL_CLASS_JAVA_DOC; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 37 | import static org.onosproject.yangutils.utils.UtilConstants.INPUT; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 38 | import static org.onosproject.yangutils.utils.UtilConstants.INTERFACE_JAVA_DOC; |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 39 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_ADD_TO_LIST; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 40 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_BUILD; |
| 41 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_BUILD_RETURN; |
| 42 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_CONSTRUCTOR; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 43 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_END_LINE; |
| 44 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_FIRST_LINE; |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 45 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_FOR_VALIDATOR; |
| 46 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_FOR_VALIDATOR_RETURN; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 47 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_GETTERS; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 48 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_MANAGER_SETTERS; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 49 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_OF; |
| 50 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_PARAM; |
| 51 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_RETURN; |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 52 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_RPC; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 53 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_SETTERS; |
| 54 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_SETTERS_COMMON; |
| 55 | import static org.onosproject.yangutils.utils.UtilConstants.LIST; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 56 | import static org.onosproject.yangutils.utils.UtilConstants.MAP; |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 57 | import static org.onosproject.yangutils.utils.UtilConstants.MAX_RANGE; |
| 58 | import static org.onosproject.yangutils.utils.UtilConstants.MIN_RANGE; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 59 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 60 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE_ASTERISK; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 61 | import static org.onosproject.yangutils.utils.UtilConstants.OBJECT; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 62 | import static org.onosproject.yangutils.utils.UtilConstants.OBJECT_STRING; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 63 | import static org.onosproject.yangutils.utils.UtilConstants.OF; |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 64 | import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM_JAVA_DOC; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 65 | import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE_INFO_JAVADOC; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 66 | import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE_INFO_JAVADOC_OF_CHILD; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 67 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 68 | import static org.onosproject.yangutils.utils.UtilConstants.QUEUE; |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 69 | import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_STRING; |
| 70 | import static org.onosproject.yangutils.utils.UtilConstants.RPC_OUTPUT_STRING; |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 71 | import static org.onosproject.yangutils.utils.UtilConstants.SET; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 72 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 73 | import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 74 | import static org.onosproject.yangutils.utils.UtilConstants.VALUE; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 75 | import static org.onosproject.yangutils.utils.UtilConstants.VOID; |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 76 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 77 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; |
| 78 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 79 | |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 80 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 81 | * Represents javadoc for the generated classes. |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 82 | */ |
| 83 | public final class JavaDocGen { |
| 84 | |
| 85 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 86 | * Creates an instance of java doc gen. |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 87 | */ |
| 88 | private JavaDocGen() { |
| 89 | } |
| 90 | |
| 91 | /** |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 92 | * Returns java docs. |
| 93 | * |
Bharat saraswal | e304c25 | 2016-08-16 20:56:20 +0530 | [diff] [blame] | 94 | * @param type java doc type |
| 95 | * @param name name of the YangNode |
| 96 | * @param isList is list attribute |
| 97 | * @param pluginConfig plugin configurations |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 98 | * @param compilerAnnotation compiler annotations for user defined data type |
Bharat saraswal | 2da23bf | 2016-08-25 15:28:39 +0530 | [diff] [blame] | 99 | * @return javaDocs. |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 100 | */ |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 101 | public static String getJavaDoc(JavaDocType type, String name, boolean isList, YangPluginConfig pluginConfig, |
Bharat saraswal | e304c25 | 2016-08-16 20:56:20 +0530 | [diff] [blame] | 102 | String compilerAnnotation) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 103 | |
Gaurav Agrawal | bfce934 | 2016-06-15 13:58:01 +0530 | [diff] [blame] | 104 | name = YangIoUtils.getSmallCase(getCamelCase(name, pluginConfig.getConflictResolver())); |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 105 | switch (type) { |
| 106 | case IMPL_CLASS: { |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 107 | return generateForClass(name); |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 108 | } |
| 109 | case BUILDER_CLASS: { |
| 110 | return generateForBuilderClass(name); |
| 111 | } |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 112 | case OPERATION_CLASS: { |
| 113 | return generateForOpParamClass(name); |
| 114 | } |
| 115 | case OPERATION_BUILDER_CLASS: { |
| 116 | return generateForOpParamClass(name); |
| 117 | } |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 118 | case INTERFACE: { |
| 119 | return generateForInterface(name); |
| 120 | } |
| 121 | case BUILDER_INTERFACE: { |
| 122 | return generateForBuilderInterface(name); |
| 123 | } |
| 124 | case PACKAGE_INFO: { |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 125 | return generateForPackage(name, isList); |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 126 | } |
| 127 | case GETTER_METHOD: { |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 128 | return generateForGetters(name, isList, compilerAnnotation); |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 129 | } |
| 130 | case TYPE_DEF_SETTER_METHOD: { |
| 131 | return generateForTypeDefSetter(name); |
| 132 | } |
| 133 | case SETTER_METHOD: { |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 134 | return generateForSetters(name, isList, compilerAnnotation); |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 135 | } |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 136 | case MANAGER_SETTER_METHOD: { |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 137 | return generateForManagerSetters(name, isList, compilerAnnotation); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 138 | } |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 139 | case OF_METHOD: { |
| 140 | return generateForOf(name); |
| 141 | } |
| 142 | case DEFAULT_CONSTRUCTOR: { |
| 143 | return generateForDefaultConstructors(name); |
| 144 | } |
| 145 | case BUILD_METHOD: { |
| 146 | return generateForBuild(name); |
| 147 | } |
| 148 | case TYPE_CONSTRUCTOR: { |
| 149 | return generateForTypeConstructor(name); |
| 150 | } |
| 151 | case FROM_METHOD: { |
| 152 | return generateForFromString(name); |
| 153 | } |
| 154 | case ENUM_CLASS: { |
| 155 | return generateForEnum(name); |
| 156 | } |
| 157 | case ENUM_ATTRIBUTE: { |
| 158 | return generateForEnumAttr(name); |
| 159 | } |
| 160 | case RPC_INTERFACE: { |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 161 | return generateForRpcService(name); |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 162 | } |
| 163 | case RPC_MANAGER: { |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 164 | return generateForClass(name); |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 165 | } |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 166 | case EVENT: { |
| 167 | return generateForEvent(name); |
| 168 | } |
| 169 | case EVENT_LISTENER: { |
| 170 | return generateForEventListener(name); |
| 171 | } |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 172 | case EVENT_SUBJECT_CLASS: { |
| 173 | return generateForClass(name); |
| 174 | } |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 175 | case ADD_TO_LIST: { |
| 176 | return generateForAddToList(name); |
| 177 | } |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 178 | default: { |
| 179 | return generateForConstructors(name); |
| 180 | } |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 181 | } |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 185 | * Generates javaDocs for enum's attributes. |
| 186 | * |
| 187 | * @param name attribute name |
| 188 | * @return javaDocs |
| 189 | */ |
| 190 | private static String generateForEnumAttr(String name) { |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 191 | return EIGHT_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + EIGHT_SPACE_INDENTATION + ENUM_ATTRIBUTE_JAVADOC |
| 192 | + name + PERIOD + NEW_LINE + EIGHT_SPACE_INDENTATION + JAVA_DOC_END_LINE; |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | /** |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 196 | * Generates javaDocs for rpc method. |
| 197 | * |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 198 | * @param rpcName name of the rpc |
| 199 | * @param inputName name of input |
| 200 | * @param outputName name of output |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 201 | * @param pluginConfig plugin configurations |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 202 | * @return javaDocs of rpc method |
| 203 | */ |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 204 | public static String generateJavaDocForRpc(String rpcName, String inputName, String outputName, |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 205 | YangPluginConfig pluginConfig) { |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 206 | rpcName = getCamelCase(rpcName, pluginConfig.getConflictResolver()); |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 207 | |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 208 | String javadoc = |
| 209 | NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_RPC |
Bharat saraswal | 5cd9e9c | 2016-05-26 23:48:38 +0530 | [diff] [blame] | 210 | + rpcName + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK; |
| 211 | if (!inputName.equals(EMPTY_STRING)) { |
| 212 | javadoc = javadoc + getInputString(inputName, rpcName); |
| 213 | } |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 214 | if (!outputName.equals(VOID)) { |
| 215 | javadoc = javadoc + getOutputString(outputName, rpcName); |
| 216 | } |
| 217 | return javadoc + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE; |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | /** |
| 221 | * Returns output string of rpc. |
| 222 | * |
| 223 | * @param outputName name of output |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 224 | * @param rpcName name of rpc |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 225 | * @return javaDocs for output string of rpc |
| 226 | */ |
| 227 | private static String getOutputString(String outputName, String rpcName) { |
| 228 | return FOUR_SPACE_INDENTATION + JAVA_DOC_RETURN + outputName + SPACE + RPC_OUTPUT_STRING + rpcName + NEW_LINE; |
| 229 | } |
| 230 | |
| 231 | /** |
| 232 | * Returns input string of rpc. |
| 233 | * |
| 234 | * @param inputName name of input |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 235 | * @param rpcName name of rpc |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 236 | * @return javaDocs for input string of rpc |
| 237 | */ |
| 238 | private static String getInputString(String inputName, String rpcName) { |
| 239 | if (inputName.equals("")) { |
| 240 | return null; |
| 241 | } else { |
| 242 | return FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + inputName + SPACE + RPC_INPUT_STRING + rpcName + NEW_LINE; |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * Generates javaDoc for the interface. |
| 248 | * |
| 249 | * @param interfaceName interface name |
| 250 | * @return javaDocs |
| 251 | */ |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 252 | private static String generateForRpcService(String interfaceName) { |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 253 | return NEW_LINE + JAVA_DOC_FIRST_LINE + INTERFACE_JAVA_DOC + interfaceName + PERIOD + NEW_LINE |
| 254 | + JAVA_DOC_END_LINE; |
| 255 | } |
| 256 | |
| 257 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 258 | * Generates javaDoc for the event. |
| 259 | * |
| 260 | * @param eventClassName event class name |
| 261 | * @return javaDocs |
| 262 | */ |
| 263 | private static String generateForEvent(String eventClassName) { |
| 264 | return NEW_LINE + JAVA_DOC_FIRST_LINE + EVENT_JAVA_DOC + eventClassName + PERIOD + NEW_LINE |
| 265 | + JAVA_DOC_END_LINE; |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * Generates javaDoc for the event listener. |
| 270 | * |
| 271 | * @param eventListenerInterfaceName event class name |
| 272 | * @return javaDocs |
| 273 | */ |
| 274 | private static String generateForEventListener(String eventListenerInterfaceName) { |
| 275 | return NEW_LINE + JAVA_DOC_FIRST_LINE + EVENT_LISTENER_JAVA_DOC + eventListenerInterfaceName |
| 276 | + PERIOD + NEW_LINE + JAVA_DOC_END_LINE; |
| 277 | } |
| 278 | |
| 279 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 280 | * Generates javaDocs for getter method. |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 281 | * |
Bharat saraswal | e304c25 | 2016-08-16 20:56:20 +0530 | [diff] [blame] | 282 | * @param attribute attribute |
| 283 | * @param isList is list attribute |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 284 | * @param compilerAnnotation compiler annotation |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 285 | * @return javaDocs |
| 286 | */ |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 287 | private static String generateForGetters(String attribute, boolean isList, |
Bharat saraswal | e304c25 | 2016-08-16 20:56:20 +0530 | [diff] [blame] | 288 | String compilerAnnotation) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 289 | |
| 290 | String getter = NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 291 | + JAVA_DOC_GETTERS + attribute + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 292 | + FOUR_SPACE_INDENTATION + JAVA_DOC_RETURN; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 293 | if (isList) { |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 294 | String attrParam; |
| 295 | if (compilerAnnotation != null) { |
| 296 | switch (compilerAnnotation) { |
| 297 | case QUEUE: { |
| 298 | attrParam = QUEUE.toLowerCase() + SPACE + OF + SPACE; |
| 299 | break; |
| 300 | } |
| 301 | case SET: { |
| 302 | attrParam = SET.toLowerCase() + SPACE + OF + SPACE; |
| 303 | break; |
| 304 | } |
| 305 | case LIST: { |
| 306 | attrParam = LIST.toLowerCase() + SPACE + OF + SPACE; |
| 307 | break; |
| 308 | } |
| 309 | default: { |
| 310 | attrParam = LIST.toLowerCase() + SPACE + OF + SPACE; |
| 311 | } |
| 312 | } |
| 313 | } else { |
| 314 | attrParam = LIST.toLowerCase() + SPACE + OF + SPACE; |
| 315 | } |
| 316 | getter = getter + attrParam; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 317 | } else { |
| 318 | getter = getter + VALUE + SPACE + OF + SPACE; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 319 | } |
| 320 | |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 321 | getter = getter + attribute + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 322 | return getter; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | /** |
| 326 | * Generates javaDocs for setter method. |
| 327 | * |
Bharat saraswal | e304c25 | 2016-08-16 20:56:20 +0530 | [diff] [blame] | 328 | * @param attribute attribute |
| 329 | * @param isList is list attribute |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 330 | * @param compilerAnnotation compiler annotation |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 331 | * @return javaDocs |
| 332 | */ |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 333 | private static String generateForSetters(String attribute, boolean isList, |
Bharat saraswal | e304c25 | 2016-08-16 20:56:20 +0530 | [diff] [blame] | 334 | String compilerAnnotation) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 335 | |
| 336 | String setter = NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 337 | + JAVA_DOC_SETTERS + attribute + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 338 | + FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + attribute + SPACE; |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 339 | |
| 340 | String attributeParam; |
| 341 | if (compilerAnnotation != null) { |
| 342 | switch (compilerAnnotation) { |
| 343 | case QUEUE: { |
| 344 | attributeParam = QUEUE.toLowerCase() + SPACE + OF + SPACE; |
| 345 | setter = setter + attributeParam; |
| 346 | break; |
| 347 | } |
| 348 | case SET: { |
| 349 | attributeParam = SET.toLowerCase() + SPACE + OF + SPACE; |
| 350 | setter = setter + attributeParam; |
| 351 | break; |
| 352 | } |
| 353 | case LIST: { |
| 354 | attributeParam = LIST.toLowerCase() + SPACE + OF + SPACE; |
| 355 | setter = setter + attributeParam; |
| 356 | break; |
| 357 | } |
| 358 | default: { |
| 359 | |
| 360 | } |
| 361 | } |
| 362 | } else if (isList) { |
| 363 | attributeParam = LIST.toLowerCase() + SPACE + OF + SPACE; |
| 364 | setter = setter + attributeParam; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 365 | } else { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 366 | setter = setter + VALUE + SPACE + OF + SPACE; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 367 | } |
Bharat saraswal | 5cd9e9c | 2016-05-26 23:48:38 +0530 | [diff] [blame] | 368 | setter = setter + attribute + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_RETURN + BUILDER_OBJECT |
| 369 | + attribute |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 370 | + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 371 | return setter; |
| 372 | } |
| 373 | |
| 374 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 375 | * Generates javaDocs for setter method. |
| 376 | * |
Bharat saraswal | e304c25 | 2016-08-16 20:56:20 +0530 | [diff] [blame] | 377 | * @param attribute attribute |
| 378 | * @param isList is list attribute |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 379 | * @param compilerAnnotation compiler annotation |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 380 | * @return javaDocs |
| 381 | */ |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 382 | private static String generateForManagerSetters(String attribute, boolean isList, |
Bharat saraswal | e304c25 | 2016-08-16 20:56:20 +0530 | [diff] [blame] | 383 | String compilerAnnotation) { |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 384 | |
| 385 | String setter = NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION |
| 386 | + JAVA_DOC_MANAGER_SETTERS + attribute + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK |
| 387 | + FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + attribute + SPACE; |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 388 | |
| 389 | String attributeParam; |
| 390 | if (compilerAnnotation != null) { |
| 391 | switch (compilerAnnotation) { |
| 392 | case QUEUE: { |
| 393 | attributeParam = QUEUE.toLowerCase() + SPACE + OF + SPACE; |
| 394 | setter = setter + attributeParam; |
| 395 | break; |
| 396 | } |
| 397 | case SET: { |
| 398 | attributeParam = SET.toLowerCase() + SPACE + OF + SPACE; |
| 399 | setter = setter + attributeParam; |
| 400 | break; |
| 401 | } |
| 402 | case LIST: { |
| 403 | attributeParam = LIST.toLowerCase() + SPACE + OF + SPACE; |
| 404 | setter = setter + attributeParam; |
| 405 | break; |
| 406 | } |
| 407 | default: { |
| 408 | |
| 409 | } |
| 410 | } |
| 411 | } else if (isList) { |
| 412 | attributeParam = LIST.toLowerCase() + SPACE + OF + SPACE; |
| 413 | setter = setter + attributeParam; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 414 | } else { |
| 415 | setter = setter + VALUE + SPACE + OF + SPACE; |
| 416 | } |
| 417 | setter = setter + attribute |
| 418 | + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE; |
| 419 | return setter; |
| 420 | } |
| 421 | |
| 422 | /** |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 423 | * Generates javaDocs for of method. |
| 424 | * |
| 425 | * @param attribute attribute |
| 426 | * @return javaDocs |
| 427 | */ |
| 428 | private static String generateForOf(String attribute) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 429 | return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_OF |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 430 | + attribute + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK + FOUR_SPACE_INDENTATION |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 431 | + JAVA_DOC_PARAM + VALUE + SPACE + VALUE + SPACE + OF + SPACE + attribute + NEW_LINE |
| 432 | + FOUR_SPACE_INDENTATION + JAVA_DOC_RETURN + OBJECT + SPACE + OF + SPACE + attribute + NEW_LINE |
| 433 | + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 437 | * Generates javaDocs for from method. |
| 438 | * |
| 439 | * @param attribute attribute |
| 440 | * @return javaDocs |
| 441 | */ |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 442 | private static String generateForFromString(String attribute) { |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 443 | |
| 444 | return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_OF |
| 445 | + attribute + SPACE + FROM_STRING_METHOD_NAME + SPACE + INPUT + SPACE + STRING_DATA_TYPE + PERIOD |
| 446 | + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK + FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 447 | + FROM_STRING_PARAM_NAME + SPACE + INPUT + SPACE + STRING_DATA_TYPE + NEW_LINE |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 448 | + FOUR_SPACE_INDENTATION + JAVA_DOC_RETURN + OBJECT + SPACE + OF + SPACE + attribute + NEW_LINE |
| 449 | + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE; |
| 450 | } |
| 451 | |
| 452 | /** |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 453 | * Generates javaDocs for typedef setter method. |
| 454 | * |
| 455 | * @param attribute attribute |
| 456 | * @return javaDocs |
| 457 | */ |
| 458 | private static String generateForTypeDefSetter(String attribute) { |
Vidyashree Rama | 1396065 | 2016-04-26 15:06:06 +0530 | [diff] [blame] | 459 | return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 460 | + JAVA_DOC_SETTERS_COMMON + attribute + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 461 | + FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + VALUE + SPACE + VALUE + SPACE + OF + SPACE + attribute |
Vidyashree Rama | 1396065 | 2016-04-26 15:06:06 +0530 | [diff] [blame] | 462 | + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 466 | * Generates javaDocs for the impl class. |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 467 | * |
| 468 | * @param className class name |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 469 | * @return javaDocs |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 470 | */ |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 471 | private static String generateForClass(String className) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 472 | return NEW_LINE + JAVA_DOC_FIRST_LINE + IMPL_CLASS_JAVA_DOC + className + PERIOD + NEW_LINE + JAVA_DOC_END_LINE; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 473 | } |
| 474 | |
| 475 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 476 | * Generates javaDocs for enum. |
| 477 | * |
| 478 | * @param className enum class name |
| 479 | * @return javaDocs |
| 480 | */ |
| 481 | private static String generateForEnum(String className) { |
| 482 | return NEW_LINE + NEW_LINE + JAVA_DOC_FIRST_LINE + ENUM_CLASS_JAVADOC + className + PERIOD + NEW_LINE |
| 483 | + JAVA_DOC_END_LINE; |
| 484 | } |
| 485 | |
| 486 | /** |
| 487 | * Generates javaDocs for the builder class. |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 488 | * |
| 489 | * @param className class name |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 490 | * @return javaDocs |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 491 | */ |
| 492 | private static String generateForBuilderClass(String className) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 493 | return NEW_LINE + JAVA_DOC_FIRST_LINE + BUILDER_CLASS_JAVA_DOC + className + PERIOD + NEW_LINE |
| 494 | + JAVA_DOC_END_LINE; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 495 | } |
| 496 | |
| 497 | /** |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 498 | * Generates javaDocs for the op param class. |
| 499 | * |
| 500 | * @param className class name |
| 501 | * @return javaDocs |
| 502 | */ |
| 503 | private static String generateForOpParamClass(String className) { |
| 504 | return NEW_LINE + JAVA_DOC_FIRST_LINE + OP_PARAM_JAVA_DOC + className + PERIOD + NEW_LINE |
| 505 | + JAVA_DOC_END_LINE; |
| 506 | } |
| 507 | |
| 508 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 509 | * Generates javaDoc for the interface. |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 510 | * |
| 511 | * @param interfaceName interface name |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 512 | * @return javaDocs |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 513 | */ |
| 514 | private static String generateForInterface(String interfaceName) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 515 | return NEW_LINE + JAVA_DOC_FIRST_LINE + INTERFACE_JAVA_DOC + interfaceName + PERIOD + NEW_LINE |
| 516 | + JAVA_DOC_END_LINE; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 520 | * Generates javaDoc for the builder interface. |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 521 | * |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 522 | * @param builderForName builder for name |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 523 | * @return javaDocs |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 524 | */ |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 525 | private static String generateForBuilderInterface(String builderForName) { |
| 526 | return JAVA_DOC_FIRST_LINE + BUILDER_INTERFACE_JAVA_DOC + builderForName + PERIOD + NEW_LINE |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 527 | + JAVA_DOC_END_LINE; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 528 | } |
| 529 | |
| 530 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 531 | * Generates javaDocs for package-info. |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 532 | * |
| 533 | * @param packageName package name |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 534 | * @param isChildNode is it child node |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 535 | * @return javaDocs |
| 536 | */ |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 537 | private static String generateForPackage(String packageName, boolean isChildNode) { |
| 538 | String javaDoc = JAVA_DOC_FIRST_LINE + PACKAGE_INFO_JAVADOC + packageName; |
| 539 | if (isChildNode) { |
| 540 | javaDoc = javaDoc + PACKAGE_INFO_JAVADOC_OF_CHILD; |
| 541 | } |
| 542 | return javaDoc + PERIOD + NEW_LINE + JAVA_DOC_END_LINE; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 543 | } |
| 544 | |
| 545 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 546 | * Generates javaDocs for default constructor. |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 547 | * |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 548 | * @param className class name |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 549 | * @return javaDocs |
| 550 | */ |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 551 | private static String generateForDefaultConstructors(String className) { |
| 552 | return FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_CONSTRUCTOR + className |
| 553 | + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 557 | * Generates javaDocs for constructor with parameters. |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 558 | * |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 559 | * @param className class name |
| 560 | * @return javaDocs |
| 561 | */ |
| 562 | private static String generateForConstructors(String className) { |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 563 | return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_CONSTRUCTOR |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 564 | + className + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 565 | + FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + BUILDER.toLowerCase() + OBJECT + SPACE + BUILDER_OBJECT |
| 566 | + className + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 570 | * Generates javaDocs for build. |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 571 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 572 | * @param buildName builder name |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 573 | * @return javaDocs |
| 574 | */ |
| 575 | private static String generateForBuild(String buildName) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 576 | return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_BUILD |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 577 | + buildName + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK + FOUR_SPACE_INDENTATION |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 578 | + JAVA_DOC_RETURN + JAVA_DOC_BUILD_RETURN + buildName + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION |
| 579 | + JAVA_DOC_END_LINE; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 580 | } |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 581 | |
| 582 | /** |
| 583 | * Generates javaDocs for type constructor. |
| 584 | * |
| 585 | * @param attribute attribute string |
| 586 | * @return javaDocs for type constructor |
| 587 | */ |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 588 | private static String generateForTypeConstructor(String attribute) { |
Vidyashree Rama | 1396065 | 2016-04-26 15:06:06 +0530 | [diff] [blame] | 589 | return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_CONSTRUCTOR |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 590 | + attribute + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK + FOUR_SPACE_INDENTATION |
| 591 | + JAVA_DOC_PARAM + VALUE + SPACE + VALUE + SPACE + OF + SPACE + attribute + NEW_LINE |
Vidyashree Rama | 1396065 | 2016-04-26 15:06:06 +0530 | [diff] [blame] | 592 | + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 593 | } |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 594 | |
| 595 | /** |
| 596 | * Generates javaDocs for add augmentation method. |
| 597 | * |
| 598 | * @return javaDocs |
| 599 | */ |
| 600 | public static String generateForAddAugmentation() { |
| 601 | return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION |
| 602 | + JAVA_DOC_SETTERS_COMMON + getSmallCase(YANG_AUGMENTED_INFO) + MAP + PERIOD + NEW_LINE + |
| 603 | FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK + FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + VALUE + SPACE + |
| 604 | VALUE + SPACE + OF + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + NEW_LINE + FOUR_SPACE_INDENTATION |
| 605 | + JAVA_DOC_PARAM + CLASS + OBJECT_STRING + SPACE + |
| 606 | VALUE + SPACE + OF + SPACE + AUGMENTED + CLASS + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE; |
| 607 | } |
| 608 | |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 609 | /** |
| 610 | * Returns javadoc for get augmentation method. |
| 611 | * |
| 612 | * @return javadoc for get augmentation method |
| 613 | */ |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 614 | public static String generateForGetAugmentation() { |
| 615 | return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION |
| 616 | + JAVA_DOC_GETTERS + getSmallCase(YANG_AUGMENTED_INFO) + PERIOD + NEW_LINE + |
| 617 | FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK + FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + CLASS + |
| 618 | OBJECT_STRING + SPACE + VALUE + SPACE + OF + SPACE + AUGMENTED + CLASS + NEW_LINE + |
| 619 | FOUR_SPACE_INDENTATION + JAVA_DOC_RETURN + VALUE + SPACE + |
| 620 | OF + SPACE + YANG_AUGMENTED_INFO + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE; |
| 621 | } |
| 622 | |
| 623 | /** |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 624 | * Returns javadoc for validator method. |
| 625 | * |
| 626 | * @return javadoc for validator method |
| 627 | */ |
| 628 | public static String generateForValidatorMethod() { |
| 629 | return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + |
| 630 | JAVA_DOC_FOR_VALIDATOR + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK + |
| 631 | FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + MIN_RANGE + SPACE + MIN_RANGE + SPACE + OF + SPACE + |
| 632 | VALUE + NEW_LINE + |
| 633 | FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + MAX_RANGE + SPACE + MAX_RANGE + SPACE + OF + SPACE + VALUE + |
| 634 | NEW_LINE + |
| 635 | FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + VALUE + SPACE + VALUE + NEW_LINE + |
| 636 | FOUR_SPACE_INDENTATION + JAVA_DOC_FOR_VALIDATOR_RETURN + NEW_LINE + FOUR_SPACE_INDENTATION + |
| 637 | JAVA_DOC_END_LINE; |
| 638 | } |
| 639 | |
| 640 | /** |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 641 | * Generates javaDocs for type constructor. |
| 642 | * |
| 643 | * @param attribute attribute string |
| 644 | * @return javaDocs for type constructor |
| 645 | */ |
| 646 | public static String generateForGetMethodWithAttribute(String attribute) { |
| 647 | return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_GETTERS |
| 648 | + attribute + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK + FOUR_SPACE_INDENTATION |
Bharat saraswal | e304c25 | 2016-08-16 20:56:20 +0530 | [diff] [blame] | 649 | + JAVA_DOC_PARAM + getSmallCase(attribute) + SPACE + VALUE + SPACE + OF + SPACE + attribute + NEW_LINE |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 650 | + FOUR_SPACE_INDENTATION + JAVA_DOC_RETURN + VALUE + SPACE + OF + SPACE + attribute + NEW_LINE |
| 651 | + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE; |
| 652 | } |
| 653 | |
| 654 | /** |
| 655 | * Returns javaDocs for add to list method. |
| 656 | * |
| 657 | * @param attribute attribute |
| 658 | * @return javaDocs |
| 659 | */ |
| 660 | private static String generateForAddToList(String attribute) { |
| 661 | String javadoc = NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION |
| 662 | + JAVA_DOC_ADD_TO_LIST + attribute + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK |
| 663 | + FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + VALUE + SPACE; |
| 664 | javadoc = javadoc + VALUE + SPACE + OF + SPACE; |
VinodKumarS-Huawei | 8f16422 | 2016-08-31 15:47:30 +0530 | [diff] [blame] | 665 | javadoc = javadoc + attribute + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_RETURN + BUILDER_OBJECT |
| 666 | + attribute |
| 667 | + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE; |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 668 | return javadoc; |
| 669 | } |
| 670 | |
| 671 | /** |
| 672 | * Generates for builder method. |
| 673 | * |
| 674 | * @param attribute attribute |
| 675 | * @return javaDocs |
| 676 | */ |
| 677 | public static String generateForBuilderMethod(String attribute) { |
| 678 | |
| 679 | String javadoc = FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION |
| 680 | + JAVA_DOC_GETTERS + attribute + BUILDER + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION |
| 681 | + NEW_LINE_ASTERISK + FOUR_SPACE_INDENTATION + JAVA_DOC_RETURN; |
| 682 | javadoc = javadoc + VALUE + SPACE + OF + SPACE; |
| 683 | javadoc = javadoc + attribute + BUILDER + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE; |
| 684 | return javadoc; |
| 685 | } |
| 686 | |
| 687 | |
| 688 | /** |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 689 | * JavaDocs types. |
| 690 | */ |
| 691 | public enum JavaDocType { |
| 692 | |
| 693 | /** |
| 694 | * For class. |
| 695 | */ |
| 696 | IMPL_CLASS, |
| 697 | |
| 698 | /** |
| 699 | * For builder class. |
| 700 | */ |
| 701 | BUILDER_CLASS, |
| 702 | |
| 703 | /** |
| 704 | * For interface. |
| 705 | */ |
| 706 | INTERFACE, |
| 707 | |
| 708 | /** |
| 709 | * For builder interface. |
| 710 | */ |
| 711 | BUILDER_INTERFACE, |
| 712 | |
| 713 | /** |
| 714 | * For package-info. |
| 715 | */ |
| 716 | PACKAGE_INFO, |
| 717 | |
| 718 | /** |
| 719 | * For getters. |
| 720 | */ |
| 721 | GETTER_METHOD, |
| 722 | |
| 723 | /** |
| 724 | * For rpc service. |
| 725 | */ |
| 726 | RPC_INTERFACE, |
| 727 | |
| 728 | /** |
| 729 | * For rpc manager. |
| 730 | */ |
| 731 | RPC_MANAGER, |
| 732 | |
| 733 | /** |
| 734 | * For event. |
| 735 | */ |
| 736 | EVENT, |
| 737 | |
| 738 | /** |
| 739 | * For event listener. |
| 740 | */ |
| 741 | EVENT_LISTENER, |
| 742 | |
| 743 | /** |
| 744 | * For setters. |
| 745 | */ |
| 746 | SETTER_METHOD, |
| 747 | |
| 748 | /** |
| 749 | * For type def's setters. |
| 750 | */ |
| 751 | TYPE_DEF_SETTER_METHOD, |
| 752 | |
| 753 | /** |
| 754 | * For of method. |
| 755 | */ |
| 756 | OF_METHOD, |
| 757 | |
| 758 | /** |
| 759 | * For default constructor. |
| 760 | */ |
| 761 | DEFAULT_CONSTRUCTOR, |
| 762 | |
| 763 | /** |
| 764 | * For constructor. |
| 765 | */ |
| 766 | CONSTRUCTOR, |
| 767 | |
| 768 | /** |
| 769 | * For from method. |
| 770 | */ |
| 771 | FROM_METHOD, |
| 772 | |
| 773 | /** |
| 774 | * For type constructor. |
| 775 | */ |
| 776 | TYPE_CONSTRUCTOR, |
| 777 | |
| 778 | /** |
| 779 | * For build. |
| 780 | */ |
| 781 | BUILD_METHOD, |
| 782 | |
| 783 | /** |
| 784 | * For enum. |
| 785 | */ |
| 786 | ENUM_CLASS, |
| 787 | |
| 788 | /** |
| 789 | * For enum's attributes. |
| 790 | */ |
| 791 | ENUM_ATTRIBUTE, |
| 792 | |
| 793 | /** |
| 794 | * For manager setters. |
| 795 | */ |
| 796 | MANAGER_SETTER_METHOD, |
| 797 | |
| 798 | /** |
| 799 | * For event subject. |
| 800 | */ |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 801 | EVENT_SUBJECT_CLASS, |
| 802 | |
| 803 | /** |
| 804 | * For operation. |
| 805 | */ |
| 806 | OPERATION_CLASS, |
| 807 | |
| 808 | /** |
| 809 | * For operation builder. |
| 810 | */ |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 811 | OPERATION_BUILDER_CLASS, |
| 812 | |
| 813 | /** |
| 814 | * For add to list. |
| 815 | */ |
| 816 | ADD_TO_LIST, |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 817 | } |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 818 | |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 819 | } |