[ONOS-4829] Augmented data method generator implmentation.
Change-Id: I0cb68dd10a748e5b66eec0b832574f408a23ba5c
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
index 8811dfa..44dddea 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
@@ -97,11 +97,6 @@
public static final String JAVA_DOC_RETURN = " * @return ";
/**
- * JavaDocs's throw annotation.
- */
- public static final String JAVA_DOC_THROWS = " * @throws ";
-
- /**
* JavaDocs's description for setter method.
*/
public static final String JAVA_DOC_SETTERS = " * Returns the builder object of ";
@@ -307,11 +302,6 @@
public static final String IDENTITYREF = "identityref";
/**
- * Static attribute for instance identifier string.
- */
- public static final String INSTANCE_IDENTIFIER = "instance-identifier";
-
- /**
* Static attribute for output variable of rpc.
*/
public static final String RPC_INPUT_VAR_NAME = "inputVar";
@@ -332,16 +322,6 @@
public static final String ADD = "+";
/**
- * Static attribute for asterisk.
- */
- public static final String ASTERISK = "*";
-
- /**
- * Static attribute for at.
- */
- public static final String AT = "@";
-
- /**
* Static attribute for quotes.
*/
public static final String QUOTES = "\"";
@@ -357,6 +337,21 @@
public static final String COMMA = ",";
/**
+ * Static attribute for class.
+ */
+ public static final String CLASS_STRING = "Class";
+
+ /**
+ * Static attribute for put.
+ */
+ public static final String PUT = "put";
+
+ /**
+ * Static attribute for get.
+ */
+ public static final String GET = "get";
+
+ /**
* Static attribute for slash character.
*/
public static final char CHAR_OF_SLASH = '/';
@@ -432,11 +427,6 @@
public static final String VALUE = "value";
/**
- * Static attribute for enumValue syntax.
- */
- public static final String ENUM_VALUE = "enumValue";
-
- /**
* Static attribute for suffix s.
*/
public static final String SUFFIX_S = "s";
@@ -447,16 +437,6 @@
public static final String IF = "if";
/**
- * Static attribute for for.
- */
- public static final String FOR = "for";
-
- /**
- * Static attribute for while.
- */
- public static final String WHILE = "while";
-
- /**
* Static attribute for of.
*/
public static final String OF = "of";
@@ -532,11 +512,6 @@
public static final String OPEN_PARENTHESIS = "(";
/**
- * Static attribute for clear syntax.
- */
- public static final String CLEAR = "clear";
-
- /**
* Static attribute for switch syntax.
*/
public static final String SWITCH = "switch";
@@ -592,11 +567,6 @@
public static final String FOUR_SPACE_INDENTATION = " ";
/**
- * Static attribute for not syntax.
- */
- public static final String NOT = "!";
-
- /**
* Static attribute for try syntax.
*/
public static final String TRY = "try";
@@ -667,11 +637,6 @@
public static final String ABSTRACT = "abstract";
/**
- * Static attribute for protected modifier.
- */
- public static final String PROTECTED = "protected";
-
- /**
* Void java type.
*/
public static final String VOID = "void";
@@ -732,11 +697,6 @@
public static final String LONG = "long";
/**
- * Float java built in type.
- */
- public static final String FLOAT = "float";
-
- /**
* Double java built in type.
*/
public static final String DOUBLE = "double";
@@ -767,14 +727,9 @@
public static final String LONG_WRAPPER = "Long";
/**
- * YangUint64 java built in wrapper type.
+ * Static varibale for question mark.
*/
- public static final String YANG_UINT64 = "YangUint64";
-
- /**
- * Double java built in wrapper type.
- */
- public static final String DOUBLE_WRAPPER = "Double";
+ public static final String QUESTION_MARK = "?";
/**
* List of keywords in java, this is used for checking if the input does not contain these keywords.
@@ -977,11 +932,22 @@
public static final String OVERRIDE = "@Override";
/**
- * Static attribute for new line.
+ * Static attribute for collections.
*/
public static final String COLLECTION_IMPORTS = "java.util";
/**
+ * Static attribute for map.
+ */
+ public static final String MAP = "Map";
+
+ /**
+ * Static attribute for hash map.
+ */
+ public static final String HASH_MAP = "HashMap";
+
+
+ /**
* Static attribute for more object import package.
*/
public static final String GOOGLE_MORE_OBJECT_IMPORT_PKG = "com.google.common.base";
@@ -1007,25 +973,14 @@
public static final String JAVA_UTIL_OBJECTS_IMPORT_CLASS = "Objects;\n";
/**
- * Static attribute for AugmentationHolder class import package.
- */
- public static final String PROVIDED_AUGMENTATION_CLASS_IMPORT_PKG =
- "org.onosproject.yangutils.utils";
-
- /**
- * Static attribute for AugmentationHolder class import class.
- */
- public static final String AUGMENTATION_HOLDER_CLASS_IMPORT_CLASS = "AugmentationHolder;\n";
-
- /**
* Static attribute for AugmentedInfo class import package.
*/
- public static final String AUGMENTED_INFO_CLASS_IMPORT_PKG = "org.onosproject.yangutils.utils";
+ public static final String YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG = "org.onosproject.yangutils.datamodel";
/**
* Static attribute for AugmentedInfo class import class.
*/
- public static final String AUGMENTED_INFO_CLASS_IMPORT_CLASS = "AugmentedInfo;\n";
+ public static final String YANG_AUGMENTED_INFO_CLASS_IMPORT_CLASS = "YangAugmentedInfo;\n";
/**
* Static attribute for augmentation class.
@@ -1033,19 +988,14 @@
public static final String AUGMENTATION = "Augmentation";
/**
- * Static attribute for AugmentationHolder class.
- */
- public static final String AUGMENTATION_HOLDER = "AugmentationHolder";
-
- /**
* Static attribute for AugmentedInfo class.
*/
- public static final String AUGMENTED_INFO = "AugmentedInfo";
+ public static final String YANG_AUGMENTED_INFO = "YangAugmentedInfo";
/**
- * Static attribute for augmentable.
+ * Static attribute for augmented.
*/
- public static final String AUGMENTABLE = "Augmentable";
+ public static final String AUGMENTED = "Augmented";
/**
* Static attribute for list.
@@ -1053,11 +1003,6 @@
public static final String LIST = "List";
/**
- * Static attribute for array list.
- */
- public static final String ARRAY_LIST = "ArrayList";
-
- /**
* Comment to be added for autogenerated impl methods.
*/
public static final String YANG_UTILS_TODO = "//TODO: YANG utils generated code";
@@ -1166,16 +1111,6 @@
public static final String EVENT_LISTENER = "EventListener";
/**
- * Static attribute for YANG types package.
- */
- public static final String YANG_TYPES_PKG = "org.onosproject.yangutils.datamodel.utils.builtindatatype";
-
- /**
- * Static attribute for MathContext class.
- */
- public static final String MATH_CONTEXT = "MathContext";
-
- /**
* Static attribute for YANG file error.
*/
public static final String YANG_FILE_ERROR = "YANG file error : ";
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
index 1610536..336cc52 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
@@ -16,11 +16,13 @@
package org.onosproject.yangutils.utils.io.impl;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
+import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED;
+import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO;
import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_CLASS_JAVA_DOC;
import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_INTERFACE_JAVA_DOC;
import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_OBJECT;
+import static org.onosproject.yangutils.utils.UtilConstants.CLASS;
import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.ENUM_ATTRIBUTE_JAVADOC;
import static org.onosproject.yangutils.utils.UtilConstants.ENUM_CLASS_JAVADOC;
@@ -47,9 +49,11 @@
import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_SETTERS;
import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_SETTERS_COMMON;
import static org.onosproject.yangutils.utils.UtilConstants.LIST;
+import static org.onosproject.yangutils.utils.UtilConstants.MAP;
import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE_ASTERISK;
import static org.onosproject.yangutils.utils.UtilConstants.OBJECT;
+import static org.onosproject.yangutils.utils.UtilConstants.OBJECT_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.OF;
import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE_INFO_JAVADOC;
import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE_INFO_JAVADOC_OF_CHILD;
@@ -60,6 +64,8 @@
import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE;
import static org.onosproject.yangutils.utils.UtilConstants.VALUE;
import static org.onosproject.yangutils.utils.UtilConstants.VOID;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase;
/**
* Represents javadoc for the generated classes.
@@ -73,127 +79,11 @@
}
/**
- * JavaDocs types.
- */
- public enum JavaDocType {
-
- /**
- * For class.
- */
- IMPL_CLASS,
-
- /**
- * For builder class.
- */
- BUILDER_CLASS,
-
- /**
- * For interface.
- */
- INTERFACE,
-
- /**
- * For builder interface.
- */
- BUILDER_INTERFACE,
-
- /**
- * For package-info.
- */
- PACKAGE_INFO,
-
- /**
- * For getters.
- */
- GETTER_METHOD,
-
- /**
- * For rpc service.
- */
- RPC_INTERFACE,
-
- /**
- * For rpc manager.
- */
- RPC_MANAGER,
-
- /**
- * For event.
- */
- EVENT,
-
- /**
- * For event listener.
- */
- EVENT_LISTENER,
-
- /**
- * For setters.
- */
- SETTER_METHOD,
-
- /**
- * For type def's setters.
- */
- TYPE_DEF_SETTER_METHOD,
-
- /**
- * For of method.
- */
- OF_METHOD,
-
- /**
- * For default constructor.
- */
- DEFAULT_CONSTRUCTOR,
-
- /**
- * For constructor.
- */
- CONSTRUCTOR,
-
- /**
- * For from method.
- */
- FROM_METHOD,
-
- /**
- * For type constructor.
- */
- TYPE_CONSTRUCTOR,
-
- /**
- * For build.
- */
- BUILD_METHOD,
-
- /**
- * For enum.
- */
- ENUM_CLASS,
-
- /**
- * For enum's attributes.
- */
- ENUM_ATTRIBUTE,
-
- /**
- * For manager setters.
- */
- MANAGER_SETTER_METHOD,
-
- /**
- * For event subject.
- */
- EVENT_SUBJECT_CLASS
- }
-
- /**
* Returns java docs.
*
- * @param type java doc type
- * @param name name of the YangNode
- * @param isList is list attribute
+ * @param type java doc type
+ * @param name name of the YangNode
+ * @param isList is list attribute
* @param pluginConfig plugin configurations
* @return javadocs.
*/
@@ -250,10 +140,10 @@
return generateForEnumAttr(name);
}
case RPC_INTERFACE: {
- return generateForRpcService(name);
+ return generateForRpcService(name);
}
case RPC_MANAGER: {
- return generateForClass(name);
+ return generateForClass(name);
}
case EVENT: {
return generateForEvent(name);
@@ -284,14 +174,14 @@
/**
* Generates javaDocs for rpc method.
*
- * @param rpcName name of the rpc
- * @param inputName name of input
- * @param outputName name of output
+ * @param rpcName name of the rpc
+ * @param inputName name of input
+ * @param outputName name of output
* @param pluginConfig plugin configurations
* @return javaDocs of rpc method
*/
public static String generateJavaDocForRpc(String rpcName, String inputName, String outputName,
- YangPluginConfig pluginConfig) {
+ YangPluginConfig pluginConfig) {
rpcName = getCamelCase(rpcName, pluginConfig.getConflictResolver());
String javadoc =
@@ -310,7 +200,7 @@
* Returns output string of rpc.
*
* @param outputName name of output
- * @param rpcName name of rpc
+ * @param rpcName name of rpc
* @return javaDocs for output string of rpc
*/
private static String getOutputString(String outputName, String rpcName) {
@@ -321,7 +211,7 @@
* Returns input string of rpc.
*
* @param inputName name of input
- * @param rpcName name of rpc
+ * @param rpcName name of rpc
* @return javaDocs for input string of rpc
*/
private static String getInputString(String inputName, String rpcName) {
@@ -369,7 +259,7 @@
* Generates javaDocs for getter method.
*
* @param attribute attribute
- * @param isList is list attribute
+ * @param isList is list attribute
* @return javaDocs
*/
private static String generateForGetters(String attribute, boolean isList) {
@@ -392,7 +282,7 @@
* Generates javaDocs for setter method.
*
* @param attribute attribute
- * @param isList is list attribute
+ * @param isList is list attribute
* @return javaDocs
*/
private static String generateForSetters(String attribute, boolean isList) {
@@ -416,7 +306,7 @@
* Generates javaDocs for setter method.
*
* @param attribute attribute
- * @param isList is list attribute
+ * @param isList is list attribute
* @return javaDocs
*/
private static String generateForManagerSetters(String attribute, boolean isList) {
@@ -596,4 +486,143 @@
+ JAVA_DOC_PARAM + VALUE + SPACE + VALUE + SPACE + OF + SPACE + attribute + NEW_LINE
+ FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE;
}
+
+ /**
+ * Generates javaDocs for add augmentation method.
+ *
+ * @return javaDocs
+ */
+ public static String generateForAddAugmentation() {
+ return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION
+ + JAVA_DOC_SETTERS_COMMON + getSmallCase(YANG_AUGMENTED_INFO) + MAP + PERIOD + NEW_LINE +
+ FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK + FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + VALUE + SPACE +
+ VALUE + SPACE + OF + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + NEW_LINE + FOUR_SPACE_INDENTATION
+ + JAVA_DOC_PARAM + CLASS + OBJECT_STRING + SPACE +
+ VALUE + SPACE + OF + SPACE + AUGMENTED + CLASS + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE;
+ }
+
+ public static String generateForGetAugmentation() {
+ return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION
+ + JAVA_DOC_GETTERS + getSmallCase(YANG_AUGMENTED_INFO) + PERIOD + NEW_LINE +
+ FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK + FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + CLASS +
+ OBJECT_STRING + SPACE + VALUE + SPACE + OF + SPACE + AUGMENTED + CLASS + NEW_LINE +
+ FOUR_SPACE_INDENTATION + JAVA_DOC_RETURN + VALUE + SPACE +
+ OF + SPACE + YANG_AUGMENTED_INFO + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE;
+ }
+
+ /**
+ * JavaDocs types.
+ */
+ public enum JavaDocType {
+
+ /**
+ * For class.
+ */
+ IMPL_CLASS,
+
+ /**
+ * For builder class.
+ */
+ BUILDER_CLASS,
+
+ /**
+ * For interface.
+ */
+ INTERFACE,
+
+ /**
+ * For builder interface.
+ */
+ BUILDER_INTERFACE,
+
+ /**
+ * For package-info.
+ */
+ PACKAGE_INFO,
+
+ /**
+ * For getters.
+ */
+ GETTER_METHOD,
+
+ /**
+ * For rpc service.
+ */
+ RPC_INTERFACE,
+
+ /**
+ * For rpc manager.
+ */
+ RPC_MANAGER,
+
+ /**
+ * For event.
+ */
+ EVENT,
+
+ /**
+ * For event listener.
+ */
+ EVENT_LISTENER,
+
+ /**
+ * For setters.
+ */
+ SETTER_METHOD,
+
+ /**
+ * For type def's setters.
+ */
+ TYPE_DEF_SETTER_METHOD,
+
+ /**
+ * For of method.
+ */
+ OF_METHOD,
+
+ /**
+ * For default constructor.
+ */
+ DEFAULT_CONSTRUCTOR,
+
+ /**
+ * For constructor.
+ */
+ CONSTRUCTOR,
+
+ /**
+ * For from method.
+ */
+ FROM_METHOD,
+
+ /**
+ * For type constructor.
+ */
+ TYPE_CONSTRUCTOR,
+
+ /**
+ * For build.
+ */
+ BUILD_METHOD,
+
+ /**
+ * For enum.
+ */
+ ENUM_CLASS,
+
+ /**
+ * For enum's attributes.
+ */
+ ENUM_ATTRIBUTE,
+
+ /**
+ * For manager setters.
+ */
+ MANAGER_SETTER_METHOD,
+
+ /**
+ * For event subject.
+ */
+ EVENT_SUBJECT_CLASS
+ }
}
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java
index a32d927..566e9ce 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java
@@ -103,7 +103,7 @@
* @throws IOException when fails to create package info file
*/
public static void addPackageInfo(File path, String classInfo, String pack, boolean isChildNode,
- YangPluginConfig pluginConfig)
+ YangPluginConfig pluginConfig)
throws IOException {
pack = parsePkg(pack);
@@ -385,7 +385,7 @@
/* Updates the given line with the given size conditions. */
private static StringBuilder updateString(String[] strArray, StringBuilder stringBuilder, String string,
- int lineSize) {
+ int lineSize) {
StringBuilder tempBuilder = new StringBuilder();
for (String str : strArray) {
@@ -481,7 +481,7 @@
/**
* Adds prefix, if the string begins with digit or is a java key word.
*
- * @param camelCasePrefix string for adding prefix
+ * @param camelCasePrefix string for adding prefix
* @param conflictResolver object of YANG to java naming conflict util
* @return prefixed camel case string
*/
@@ -502,7 +502,7 @@
* Applies the rule that a string does not end with a capitalized letter and capitalizes
* the letter next to a number in an array.
*
- * @param stringArray containing strings for camel case separation
+ * @param stringArray containing strings for camel case separation
* @param conflictResolver object of YANG to java naming conflict util
* @return camel case rule checked string
*/
@@ -545,7 +545,7 @@
/**
* Resolves the conflict when input has upper case.
*
- * @param stringArray containing strings for upper case conflict resolver
+ * @param stringArray containing strings for upper case conflict resolver
* @param conflictResolver object of YANG to java naming conflict util
* @return camel cased string
*/
@@ -597,7 +597,7 @@
/**
* Returns the YANG identifier name as java identifier.
*
- * @param yangIdentifier identifier in YANG file
+ * @param yangIdentifier identifier in YANG file
* @param conflictResolver object of YANG to java naming conflict util
* @return corresponding java identifier
*/