[ONOS-5198] Generated Enum class modifications
Change-Id: I62a9811ee9e695d96a42c44fecfc3c3beeb71b96
diff --git a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListener.java b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListener.java
index 93cd621..2f06387 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListener.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListener.java
@@ -27,7 +27,8 @@
import static org.onosproject.yangutils.datamodel.utils.YangConstructType.MAX_ELEMENT_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction
+ .constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat;
@@ -68,10 +69,10 @@
* (max-elements), performs validation and updates the data model tree.
*
* @param listener listener's object
- * @param ctx context object of the grammar rule
+ * @param ctx context object of the grammar rule
*/
public static void processMaxElementsEntry(TreeWalkListener listener,
- GeneratedYangParser.MaxElementsStatementContext ctx) {
+ GeneratedYangParser.MaxElementsStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, MAX_ELEMENT_DATA, "", ENTRY);
@@ -117,16 +118,20 @@
maxElementsValue = Integer.parseInt(value);
} catch (NumberFormatException e) {
ParserException parserException = new ParserException("YANG file error : " +
- YangConstructType.getYangConstructType(MAX_ELEMENT_DATA) + " value " + value + " is not " +
- "valid.");
+ YangConstructType.getYangConstructType(
+ MAX_ELEMENT_DATA) + " value " +
+ value + " is not " +
+ "valid.");
parserException.setLine(ctx.getStart().getLine());
parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
throw parserException;
}
} else {
ParserException parserException = new ParserException("YANG file error : " +
- YangConstructType.getYangConstructType(MAX_ELEMENT_DATA) + " value " + value + " is not " +
- "valid.");
+ YangConstructType.getYangConstructType(
+ MAX_ELEMENT_DATA) + " value " +
+ value + " is not " +
+ "valid.");
parserException.setLine(ctx.getStart().getLine());
parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
throw parserException;
@@ -134,4 +139,5 @@
return maxElementsValue;
}
+
}
\ No newline at end of file
diff --git a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListener.java b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListener.java
index 3fae538..27cd100 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListener.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListener.java
@@ -26,7 +26,8 @@
import static org.onosproject.yangutils.datamodel.utils.YangConstructType.MIN_ELEMENT_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction
+ .constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidNonNegativeIntegerValue;
@@ -93,7 +94,8 @@
break;
default:
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, MIN_ELEMENT_DATA,
- ctx.minValue().getText(), ENTRY));
+ ctx.minValue().getText(), ENTRY));
}
}
+
}
\ No newline at end of file
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEnumerationFragmentFiles.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEnumerationFragmentFiles.java
index 7bf3f2a..12dc41c 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEnumerationFragmentFiles.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEnumerationFragmentFiles.java
@@ -17,10 +17,6 @@
import java.io.File;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import org.onosproject.yangutils.datamodel.YangEnum;
import org.onosproject.yangutils.datamodel.YangEnumeration;
@@ -32,10 +28,10 @@
import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT32;
import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK;
import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.generateEnumAttributeString;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen
+ .generateEnumAttributeStringWithSchemaName;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEnumClassFile;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute;
import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.INT;
import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_FIRST_DIGIT;
@@ -61,21 +57,6 @@
private static final String ENUM_CLASS_FILE_NAME_SUFFIX = EMPTY_STRING;
/**
- * Current enum's value.
- */
- private int enumValue;
-
- /**
- * Contains data of enumSet.
- */
- private Map<String, Integer> enumStringMap = new HashMap<>();
-
- /**
- * Contains data of enumSet.
- */
- private List<String> enumStringList;
-
- /**
* Temporary file handle for enum class file.
*/
private File enumClassTempFileHandle;
@@ -95,8 +76,6 @@
throws IOException {
super(javaFileInfo);
- setEnumSetJavaMap(new HashMap<>());
- setEnumStringList(new ArrayList<>());
/*
* Initialize enum when generation file type matches to enum class mask.
*/
@@ -123,42 +102,6 @@
}
/**
- * Returns enum's value.
- *
- * @return enum's value
- */
- private int getEnumValue() {
- return enumValue;
- }
-
- /**
- * Sets enum's value.
- *
- * @param enumValue enum's value
- */
- private void setEnumValue(int enumValue) {
- this.enumValue = enumValue;
- }
-
- /**
- * Returns enum set java map.
- *
- * @return the enum set java map
- */
- public Map<String, Integer> getEnumSetJavaMap() {
- return enumStringMap;
- }
-
- /**
- * Sets enum set java map.
- *
- * @param map the enum set java map to set
- */
- private void setEnumSetJavaMap(Map<String, Integer> map) {
- this.enumStringMap = map;
- }
-
- /**
* Returns temporary file handle for enum class file.
*
* @return temporary file handle for enum class file
@@ -179,13 +122,14 @@
/**
* Adds enum class attributes to temporary file.
*
- * @param curEnumName current YANG enum
+ * @param yangEnum YANG enum
* @throws IOException when fails to do IO operations.
*/
- private void addAttributesForEnumClass(String curEnumName, YangPluginConfig pluginConfig)
+ private void addAttributesForEnumClass(YangPluginConfig pluginConfig, YangEnum yangEnum)
throws IOException {
appendToFile(getEnumClassTempFileHandle(),
- generateEnumAttributeString(curEnumName, getEnumValue(), pluginConfig));
+ generateEnumAttributeStringWithSchemaName(yangEnum.getNamedValue(),
+ yangEnum.getValue(), pluginConfig));
}
/**
@@ -212,15 +156,13 @@
curEnum.setNamedValue(YANG_AUTO_PREFIX + enumName);
}
}
- setEnumValue(curEnum.getValue());
- addToEnumStringList(curEnum.getNamedValue());
- addToEnumSetJavaMap(curEnum.getNamedValue(), curEnum.getValue());
- addJavaSnippetInfoToApplicableTempFiles(curEnum.getNamedValue(), pluginConfig);
+ addJavaSnippetInfoToApplicableTempFiles(pluginConfig, curEnum);
}
} else {
throw new TranslatorException("current node should be of enumeration type. " +
- curNode.getName() + " in " + curNode.getLineNumber() + " at " + curNode.getCharPosition()
- + " in " + curNode.getFileName());
+ curNode.getName() + " in " + curNode.getLineNumber() + " at " +
+ curNode.getCharPosition()
+ + " in " + curNode.getFileName());
}
}
@@ -230,7 +172,7 @@
* @param pluginConfig plugin configurations
* @return java attribute
*/
- public JavaAttributeInfo getJavaAttributeForEnum(YangPluginConfig pluginConfig) {
+ private JavaAttributeInfo getJavaAttributeForEnum(YangPluginConfig pluginConfig) {
YangJavaTypeTranslator javaType = new YangJavaTypeTranslator();
javaType.setDataType(INT32);
javaType.setDataTypeName(INT);
@@ -243,23 +185,13 @@
}
/**
- * Adds current enum name to java list.
- *
- * @param curEnumName current enum name
- */
- private void addToEnumSetJavaMap(String curEnumName, int value) {
- getEnumSetJavaMap().put(getEnumJavaAttribute(curEnumName).toUpperCase(), value);
- }
-
- /**
* Adds the new attribute info to the target generated temporary files.
*
- * @param curEnumName the attribute name that needs to be added to temporary files
- * @throws IOException IO operation fail
+ * @param yangEnum@throws IOException IO operation fail
*/
- private void addJavaSnippetInfoToApplicableTempFiles(String curEnumName, YangPluginConfig pluginConfig)
+ private void addJavaSnippetInfoToApplicableTempFiles(YangPluginConfig pluginConfig, YangEnum yangEnum)
throws IOException {
- addAttributesForEnumClass(getEnumJavaAttribute(curEnumName), pluginConfig);
+ addAttributesForEnumClass(pluginConfig, yangEnum);
}
/**
@@ -292,30 +224,4 @@
super.freeTemporaryResources(isErrorOccurred);
}
- /**
- * Adds to enum string list.
- *
- * @param curEnumValue current enum value
- */
- private void addToEnumStringList(String curEnumValue) {
- getEnumStringList().add(getEnumJavaAttribute(curEnumValue).toUpperCase());
- }
-
- /**
- * Returns enum string list.
- *
- * @return the enumStringList
- */
- public List<String> getEnumStringList() {
- return enumStringList;
- }
-
- /**
- * Sets enum string list.
- *
- * @param enumStringList the enumStringList to set
- */
- private void setEnumStringList(List<String> enumStringList) {
- this.enumStringList = enumStringList;
- }
}
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEventFragmentFiles.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEventFragmentFiles.java
index 42c5e59..6235b52 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEventFragmentFiles.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEventFragmentFiles.java
@@ -22,8 +22,8 @@
import java.util.List;
import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.utils.io.YangPluginConfig;
import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder;
+import org.onosproject.yangutils.utils.io.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS;
import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_ENUM_MASK;
@@ -41,14 +41,15 @@
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass;
import static org.onosproject.yangutils.utils.UtilConstants.COMMA;
+import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION;
import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile;
-import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.MANAGER_SETTER_METHOD;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.enumJavaDocForInnerClass;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
@@ -154,7 +155,7 @@
setJavaImportData(new JavaImportData());
setJavaFileInfo(javaFileInfo);
setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getBaseCodeGenPath(),
- getJavaFileInfo().getPackageFilePath()));
+ getJavaFileInfo().getPackageFilePath()));
addGeneratedTempFile(EVENT_ENUM_MASK);
addGeneratedTempFile(EVENT_METHOD_MASK);
@@ -250,7 +251,8 @@
this.eventSubjectJavaFileHandle = eventSubjectJavaFileHandle;
}
- public void generateJavaFile(int fileType, YangNode curNode) throws IOException {
+ public void generateJavaFile(int fileType, YangNode curNode)
+ throws IOException {
generateEventJavaFile(curNode);
generateEventListenerJavaFile(curNode);
generateEventSubjectJavaFile(curNode);
@@ -295,7 +297,7 @@
imports.add(getJavaImportData().getEventListenerImport());
String curNodeInfo = getCapitalCase(((JavaFileInfoContainer) curNode)
- .getJavaFileInfo().getJavaName());
+ .getJavaFileInfo().getJavaName());
// Creates event listener interface file.
setEventListenerJavaFileHandle(
@@ -314,7 +316,7 @@
throws IOException {
String curNodeInfo = getCapitalCase(((JavaFileInfoContainer) curNode)
- .getJavaFileInfo().getJavaName());
+ .getJavaFileInfo().getJavaName());
//Creates event interface file.
setEventSubjectJavaFileHandle(getJavaFileHandle(curNode, curNodeInfo +
@@ -424,28 +426,28 @@
throws IOException {
String currentInfo = getCapitalCase(getCamelCase(curNode.getName(),
- pluginConfig.getConflictResolver()));
+ pluginConfig.getConflictResolver()));
String notificationName = curNode.getName();
JavaQualifiedTypeInfoTranslator qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode,
- getCapitalCase(currentInfo));
+ getCapitalCase(currentInfo));
JavaAttributeInfo javaAttributeInfo = getAttributeInfoForTheData(qualifiedTypeInfo, getSmallCase(currentInfo),
- null, false, false);
+ null, false, false);
/*Adds java info for event in respective temp files.*/
- addEventEnum(notificationName, pluginConfig);
+ addEventEnum(notificationName);
addEventSubjectAttribute(javaAttributeInfo, pluginConfig);
addEventSubjectGetter(javaAttributeInfo, pluginConfig);
addEventSubjectSetter(javaAttributeInfo, pluginConfig, currentInfo);
}
/*Adds event to enum temp file.*/
- private void addEventEnum(String notificationName, YangPluginConfig pluginConfig)
+ private void addEventEnum(String notificationName)
throws IOException {
appendToFile(getEventEnumTempFileHandle(),
- getJavaDoc(ENUM_ATTRIBUTE, notificationName, false, pluginConfig, null) + FOUR_SPACE_INDENTATION
- + getEnumJavaAttribute(notificationName).toUpperCase() + COMMA + NEW_LINE);
+ enumJavaDocForInnerClass(notificationName) + EIGHT_SPACE_INDENTATION
+ + getEnumJavaAttribute(notificationName).toUpperCase() + COMMA + NEW_LINE);
}
/*Adds event method in event class*/
@@ -458,7 +460,7 @@
private void addEventSubjectAttribute(JavaAttributeInfo attr, YangPluginConfig pluginConfig)
throws IOException {
appendToFile(getEventSubjectAttributeTempFileHandle(),
- FOUR_SPACE_INDENTATION + parseAttribute(attr, pluginConfig));
+ FOUR_SPACE_INDENTATION + parseAttribute(attr, pluginConfig));
}
/*Adds getter method for event in event subject class.*/
@@ -469,8 +471,8 @@
appDataStructure = attr.getCompilerAnnotation().getYangAppDataStructure().getDataStructure().name();
}
appendToFile(getEventSubjectGetterTempFileHandle(),
- getJavaDoc(GETTER_METHOD, getCapitalCase(attr.getAttributeName()), false, pluginConfig,
- appDataStructure) + getGetterForClass(attr, GENERATE_EVENT_SUBJECT_CLASS) + NEW_LINE);
+ getJavaDoc(GETTER_METHOD, getCapitalCase(attr.getAttributeName()), false, pluginConfig,
+ appDataStructure) + getGetterForClass(attr, GENERATE_EVENT_SUBJECT_CLASS) + NEW_LINE);
}
/*Adds setter method for event in event subject class.*/
@@ -481,9 +483,9 @@
appDataStructure = attr.getCompilerAnnotation().getYangAppDataStructure().getDataStructure().name();
}
appendToFile(getEventSubjectSetterTempFileHandle(),
- getJavaDoc(MANAGER_SETTER_METHOD, getCapitalCase(attr.getAttributeName()), false, pluginConfig,
- appDataStructure) + getSetterForClass(attr, className, GENERATE_EVENT_SUBJECT_CLASS)
- + NEW_LINE);
+ getJavaDoc(MANAGER_SETTER_METHOD, getCapitalCase(attr.getAttributeName()), false, pluginConfig,
+ appDataStructure) + getSetterForClass(attr, className, GENERATE_EVENT_SUBJECT_CLASS)
+ + NEW_LINE);
}
/**
@@ -498,7 +500,7 @@
JavaFileInfoTranslator parentInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
return getFileObject(getDirPath(parentInfo), name, JAVA_FILE_EXTENSION,
- parentInfo);
+ parentInfo);
}
/**
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java
index 1d566d8..756062d 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java
@@ -1151,8 +1151,8 @@
if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0
|| (getGeneratedJavaFiles() & GENERATE_SERVICE_AND_MANAGER) != 0) {
if (!isRooNode()) {
- appendToFile(getGetterImplTempFileHandle(), getOverRideString() + getGetterForClass(attr,
- getGeneratedJavaFiles()) +
+ appendToFile(getGetterImplTempFileHandle(), getOverRideString() +
+ getGetterForClass(attr, getGeneratedJavaFiles()) +
NEW_LINE);
} else {
appendToFile(getGetterImplTempFileHandle(), getGetterForClass(attr,
@@ -1207,7 +1207,7 @@
throws IOException {
appendToFile(getLeafIdAttributeTempFileHandle(),
FOUR_SPACE_INDENTATION + generateEnumAttributeString(attr.getAttributeName(),
- value, yangPluginConfig));
+ value));
}
/**
@@ -1615,19 +1615,19 @@
}
if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) {
- JavaQualifiedTypeInfoTranslator qualifiedInfoOfFromString = getQualifiedInfoOfFromString(newAttrInfo,
- pluginConfig
- .getConflictResolver());
+ JavaQualifiedTypeInfoTranslator qualifiedInfoOfFromString =
+ getQualifiedInfoOfFromString(newAttrInfo, pluginConfig
+ .getConflictResolver());
/*
* Create a new java attribute info with qualified information of
* wrapper classes.
*/
- JavaAttributeInfo fromStringAttributeInfo = getAttributeInfoForTheData(qualifiedInfoOfFromString,
- newAttrInfo.getAttributeName(),
- newAttrInfo.getAttributeType(),
- getIsQualifiedAccessOrAddToImportList(
- qualifiedInfoOfFromString),
- false);
+ JavaAttributeInfo fromStringAttributeInfo =
+ getAttributeInfoForTheData(qualifiedInfoOfFromString, newAttrInfo.getAttributeName(),
+ newAttrInfo.getAttributeType(),
+ getIsQualifiedAccessOrAddToImportList(
+ qualifiedInfoOfFromString),
+ false);
addFromStringMethod(newAttrInfo, fromStringAttributeInfo);
}
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaNotificationTranslator.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaNotificationTranslator.java
index ce7f8b0..88a9070 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaNotificationTranslator.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaNotificationTranslator.java
@@ -17,8 +17,8 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
+
import org.onosproject.yangutils.datamodel.RpcNotificationContainer;
-import org.onosproject.yangutils.datamodel.YangLeavesHolder;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.javadatamodel.YangJavaNotification;
import org.onosproject.yangutils.translator.exception.TranslatorException;
@@ -74,10 +74,10 @@
if (javaFileInfo == null) {
throw new TranslatorException("Missing java info in java datamodel node " +
- getName() + " in " +
- getLineNumber() + " at " +
- getCharPosition()
- + " in " + getFileName());
+ getName() + " in " +
+ getLineNumber() + " at " +
+ getCharPosition()
+ + " in " + getFileName());
}
return (JavaFileInfoTranslator) javaFileInfo;
}
@@ -120,7 +120,8 @@
* @throws TranslatorException translator operation fail
*/
@Override
- public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException {
+ public void generateCodeEntry(YangPluginConfig yangPlugin)
+ throws TranslatorException {
/*
* As part of the notification support the following files needs to be generated.
@@ -156,7 +157,7 @@
JavaQualifiedTypeInfoTranslator event = new JavaQualifiedTypeInfoTranslator();
String parentInfo = getCapitalCase(((JavaFileInfoContainer) parent)
- .getJavaFileInfo().getJavaName());
+ .getJavaFileInfo().getJavaName());
event.setClassInfo(parentInfo + EVENT_STRING);
event.setPkgInfo(getJavaFileInfo().getPackage());
holder.addToExtendsList(event, parent, tempJavaServiceFragmentFiles);
@@ -173,15 +174,16 @@
* Creates a java file using the YANG notification info.
*/
@Override
- public void generateCodeExit() throws TranslatorException {
+ public void generateCodeExit()
+ throws TranslatorException {
try {
getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
} catch (IOException e) {
throw new TranslatorException("Failed to generate code for notification node " +
- getName() + " in " +
- getLineNumber() + " at " +
- getCharPosition()
- + " in " + getFileName() + " " + e.getLocalizedMessage());
+ getName() + " in " +
+ getLineNumber() + " at " +
+ getCharPosition()
+ + " in " + getFileName() + " " + e.getLocalizedMessage());
}
}
@@ -204,8 +206,7 @@
* Check if node contains leaf/leaf-list, if yes add namespace for leaf
* and leaf list.
*/
- if (this instanceof YangLeavesHolder) {
- ((YangLeavesHolder) this).setLeafNameSpaceAndAddToParentSchemaMap();
- }
+ this.setLeafNameSpaceAndAddToParentSchemaMap();
+
}
}
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java
index f1f258b..b47cc9c 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java
@@ -58,11 +58,14 @@
import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
import static org.onosproject.yangutils.utils.UtilConstants.QUESTION_MARK;
import static org.onosproject.yangutils.utils.UtilConstants.QUEUE;
+import static org.onosproject.yangutils.utils.UtilConstants.QUOTES;
+import static org.onosproject.yangutils.utils.UtilConstants.SCHEMA_NAME;
import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
import static org.onosproject.yangutils.utils.UtilConstants.SET;
import static org.onosproject.yangutils.utils.UtilConstants.SHORT_MAX_RANGE_ATTR;
import static org.onosproject.yangutils.utils.UtilConstants.SHORT_MIN_RANGE_ATTR;
import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
+import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE;
import static org.onosproject.yangutils.utils.UtilConstants.TYPE;
import static org.onosproject.yangutils.utils.UtilConstants.UINT8_MAX_RANGE_ATTR;
import static org.onosproject.yangutils.utils.UtilConstants.UINT8_MIN_RANGE_ATTR;
@@ -72,6 +75,7 @@
import static org.onosproject.yangutils.utils.UtilConstants.ULONG_MIN_RANGE_ATTR;
import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.enumJavaDocForInnerClass;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase;
@@ -190,15 +194,31 @@
/**
* Returns string for enum's attribute.
*
+ * @param name name of attribute
+ * @param value value of the enum
+ * @return string for enum's attribute
+ */
+ public static String generateEnumAttributeString(String name, int value) {
+ String enumName = getEnumJavaAttribute(name);
+ return NEW_LINE + enumJavaDocForInnerClass(name)
+ + EIGHT_SPACE_INDENTATION + enumName.toUpperCase() + OPEN_PARENTHESIS
+ + value + CLOSE_PARENTHESIS + COMMA + NEW_LINE;
+ }
+
+ /**
+ * Returns string for enum's attribute for enum class.
+ *
* @param name name of attribute
* @param value value of the enum
* @param pluginConfig plugin configurations
* @return string for enum's attribute
*/
- public static String generateEnumAttributeString(String name, int value, YangPluginConfig pluginConfig) {
+ public static String generateEnumAttributeStringWithSchemaName(String name, int value, YangPluginConfig
+ pluginConfig) {
+ String enumName = getEnumJavaAttribute(name);
return NEW_LINE + getJavaDoc(ENUM_ATTRIBUTE, name, false, pluginConfig, null)
- + EIGHT_SPACE_INDENTATION + getEnumJavaAttribute(name).toUpperCase() + OPEN_PARENTHESIS
- + value + CLOSE_PARENTHESIS + COMMA + NEW_LINE;
+ + FOUR_SPACE_INDENTATION + enumName.toUpperCase() + OPEN_PARENTHESIS
+ + value + COMMA + SPACE + QUOTES + name + QUOTES + CLOSE_PARENTHESIS + COMMA + NEW_LINE;
}
/**
@@ -271,7 +291,8 @@
*/
static String getEnumsValueAttribute(String className) {
return NEW_LINE + FOUR_SPACE_INDENTATION + PRIVATE + SPACE + INT + SPACE + getSmallCase(className)
- + SEMI_COLAN + NEW_LINE;
+ + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + PRIVATE + SPACE + STRING_DATA_TYPE + SPACE +
+ SCHEMA_NAME + SEMI_COLAN + NEW_LINE;
}
/**
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
index 2a2d97a..d3df0dc 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
@@ -25,6 +25,7 @@
import org.onosproject.yangutils.datamodel.YangCase;
import org.onosproject.yangutils.datamodel.YangChoice;
import org.onosproject.yangutils.datamodel.YangDerivedInfo;
+import org.onosproject.yangutils.datamodel.YangEnumeration;
import org.onosproject.yangutils.datamodel.YangLeavesHolder;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
@@ -37,203 +38,116 @@
import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
import org.onosproject.yangutils.translator.tojava.JavaFileInfoTranslator;
-import org.onosproject.yangutils.translator.tojava
- .JavaQualifiedTypeInfoTranslator;
-import org.onosproject.yangutils.translator.tojava
- .TempJavaCodeFragmentFilesContainer;
-import org.onosproject.yangutils.translator.tojava
- .TempJavaEnumerationFragmentFiles;
+import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator;
+import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer;
import org.onosproject.yangutils.translator.tojava.TempJavaEventFragmentFiles;
import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles;
import org.onosproject.yangutils.translator.tojava.TempJavaTypeFragmentFiles;
import org.onosproject.yangutils.utils.io.YangPluginConfig;
-import static org.onosproject.yangutils.datamodel.utils.builtindatatype
- .YangDataTypes.BINARY;
-import static org.onosproject.yangutils.datamodel.utils.builtindatatype
- .YangDataTypes.BITS;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedJavaFileType.BUILDER_CLASS_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedJavaFileType.DEFAULT_CLASS_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedJavaFileType.GENERATE_ENUM_CLASS;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedJavaFileType.GENERATE_EVENT_CLASS;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedJavaFileType.GENERATE_UNION_CLASS;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedJavaFileType.INTERFACE_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.ADD_TO_LIST_IMPL_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.ADD_TO_LIST_INTERFACE_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.ATTRIBUTES_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.ENUM_IMPL_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.EQUALS_IMPL_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.EVENT_ENUM_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.EVENT_METHOD_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.EVENT_SUBJECT_ATTRIBUTE_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.EVENT_SUBJECT_GETTER_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.EVENT_SUBJECT_SETTER_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.FROM_STRING_IMPL_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.GETTER_FOR_CLASS_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.GETTER_FOR_INTERFACE_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.HASH_CODE_IMPL_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.OF_STRING_IMPL_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.RPC_INTERFACE_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.SETTER_FOR_CLASS_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK;
-import static org.onosproject.yangutils.translator.tojava
- .GeneratedTempFileType.TO_STRING_IMPL_MASK;
-import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo
- .getAttributeInfoForTheData;
-import static org.onosproject.yangutils.translator.tojava
- .JavaQualifiedTypeInfoTranslator.getQualifiedTypeInfoOfCurNode;
-import static org.onosproject.yangutils.translator.tojava
- .TempJavaFragmentFiles.getCurNodeAsAttributeInTarget;
-import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils
- .getQualifierInfoForCasesParent;
-import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils
- .isGetSetOfRootNodeRequired;
-import static org.onosproject.yangutils.translator.tojava.utils
- .JavaCodeSnippetGen.addAugmentationAttribute;
-import static org.onosproject.yangutils.translator.tojava.utils
- .JavaCodeSnippetGen.getEnumsValueAttribute;
-import static org.onosproject.yangutils.translator.tojava.utils
- .JavaCodeSnippetGen.getEventEnumTypeStart;
-import static org.onosproject.yangutils.translator.tojava.utils
- .JavaCodeSnippetGen.getOperationAttributeForConstructor;
-import static org.onosproject.yangutils.translator.tojava.utils
- .JavaCodeSnippetGen.getOperationAttributes;
-import static org.onosproject.yangutils.translator.tojava.utils
- .JavaCodeSnippetGen.getOperationTypeAttr;
-import static org.onosproject.yangutils.translator.tojava.utils
- .JavaCodeSnippetGen.getOperationTypeEnum;
-import static org.onosproject.yangutils.translator.tojava.utils
- .JavaCodeSnippetGen.getOperationTypeForConstructor;
-import static org.onosproject.yangutils.translator.tojava.utils
- .JavaFileGeneratorUtils.getDataFromTempFileHandle;
-import static org.onosproject.yangutils.translator.tojava.utils
- .JavaFileGeneratorUtils.initiateJavaFileGeneration;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.builderMethod;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getAddAugmentInfoMethodImpl;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getAddAugmentInfoMethodInterface;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getAugmentsDataMethodForService;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getConstructorStart;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getEnumsConstructor;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getEnumsOfMethod;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getEqualsMethodClose;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getEqualsMethodOpen;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getFromStringMethodClose;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getFromStringMethodSignature;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getGetter;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getGetterForOperationType;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getGetterString;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getGettersForValueAndSelectLeaf;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getHashCodeMethodClose;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getHashCodeMethodOpen;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getInterfaceLeafIdEnumMethods;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getInterfaceLeafIdEnumSignature;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getOmitNullValueString;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getOperationAttributesGetters;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getOverRideString;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getRangeValidatorMethodForUnion;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getSetterForOperationType;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getSetterForSelectLeaf;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getSetterString;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getToStringMethodClose;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getToStringMethodOpen;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getYangAugmentInfoImpl;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getYangAugmentInfoInterface;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getYangAugmentInfoMapImpl;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.getYangAugmentInfoMapInterface;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.isLeafValueSetInterface;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.isSelectLeafSetInterface;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.processSubtreeFilteringInterface;
-import static org.onosproject.yangutils.translator.tojava.utils
- .MethodsGenerator.setSelectLeafSetInterface;
-import static org.onosproject.yangutils.translator.tojava.utils
- .SubtreeFilteringMethodsGenerator.getAugmentableSubTreeFiltering;
-import static org.onosproject.yangutils.translator.tojava.utils
- .SubtreeFilteringMethodsGenerator.getProcessChildNodeSubtreeFiltering;
-import static org.onosproject.yangutils.translator.tojava.utils
- .SubtreeFilteringMethodsGenerator.getProcessLeafListSubtreeFiltering;
-import static org.onosproject.yangutils.translator.tojava.utils
- .SubtreeFilteringMethodsGenerator.getProcessLeafSubtreeFiltering;
-import static org.onosproject.yangutils.translator.tojava.utils
- .SubtreeFilteringMethodsGenerator.getProcessSubTreeFilteringEnd;
-import static org.onosproject.yangutils.translator.tojava.utils
- .SubtreeFilteringMethodsGenerator.getProcessSubtreeFilteringStart;
-import static org.onosproject.yangutils.translator.tojava.utils
- .SubtreeFilteringMethodsGenerator.getProcessSubtreeFunctionBody;
+import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.BINARY;
+import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.BITS;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.DEFAULT_CLASS_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ADD_TO_LIST_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ADD_TO_LIST_INTERFACE_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EQUALS_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_ENUM_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_METHOD_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_SUBJECT_ATTRIBUTE_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_SUBJECT_GETTER_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_SUBJECT_SETTER_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_INTERFACE_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.HASH_CODE_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.OF_STRING_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_INTERFACE_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData;
+import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedTypeInfoOfCurNode;
+import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.getCurNodeAsAttributeInTarget;
+import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.getQualifierInfoForCasesParent;
+import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isGetSetOfRootNodeRequired;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.addAugmentationAttribute;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getEnumsValueAttribute;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getEventEnumTypeStart;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getOperationAttributeForConstructor;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getOperationAttributes;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getOperationTypeAttr;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getOperationTypeEnum;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getOperationTypeForConstructor;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen
+ .getYangAugmentedMapObjectForConstruct;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getDataFromTempFileHandle;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.builderMethod;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddAugmentInfoMethodImpl;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddAugmentInfoMethodInterface;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentsDataMethodForService;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructorStart;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEnumValueOfSchemaNameMethod;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEnumsConstructor;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEnumsOfValueMethod;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethodClose;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethodOpen;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getFromStringMethodClose;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getFromStringMethodSignature;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetter;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForOperationType;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterString;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGettersForValueAndSelectLeaf;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodClose;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodOpen;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getInterfaceLeafIdEnumMethods;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getInterfaceLeafIdEnumSignature;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOmitNullValueString;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOperationAttributesGetters;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOverRideString;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRangeValidatorMethodForUnion;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForOperationType;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForSelectLeaf;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterString;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethodClose;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethodOpen;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getYangAugmentInfoImpl;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getYangAugmentInfoInterface;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getYangAugmentInfoMapImpl;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getYangAugmentInfoMapInterface;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.isLeafValueSetInterface;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.isSelectLeafSetInterface;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.processSubtreeFilteringInterface;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.setSelectLeafSetInterface;
+import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator
+ .getAugmentableSubTreeFiltering;
+import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator
+ .getProcessChildNodeSubtreeFiltering;
+import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator
+ .getProcessLeafListSubtreeFiltering;
+import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator
+ .getProcessLeafSubtreeFiltering;
+import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator
+ .getProcessSubTreeFilteringEnd;
+import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator
+ .getProcessSubtreeFilteringStart;
+import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator
+ .getProcessSubtreeFunctionBody;
import static org.onosproject.yangutils.utils.UtilConstants.BASE64;
import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER;
import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
@@ -241,24 +155,15 @@
import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS;
import static org.onosproject.yangutils.utils.UtilConstants.COMMA;
import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT;
-import static org.onosproject.yangutils.utils.UtilConstants
- .EIGHT_SPACE_INDENTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION;
import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.ENCODE_TO_STRING;
-import static org.onosproject.yangutils.utils.UtilConstants
- .EVENT_LISTENER_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING;
-import static org.onosproject.yangutils.utils.UtilConstants
- .EVENT_SUBJECT_NAME_SUFFIX;
-import static org.onosproject.yangutils.utils.UtilConstants
- .FOUR_SPACE_INDENTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.EVENT_SUBJECT_NAME_SUFFIX;
+import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
import static org.onosproject.yangutils.utils.UtilConstants.GET_ENCODER;
-import static org.onosproject.yangutils.utils.UtilConstants.IMPORT;
import static org.onosproject.yangutils.utils.UtilConstants.INT;
-import static org.onosproject.yangutils.utils.UtilConstants
- .JAVA_UTIL_IMPORT_BASE64_CLASS;
-import static org.onosproject.yangutils.utils.UtilConstants
- .JAVA_UTIL_OBJECTS_IMPORT_PKG;
import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET;
import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS;
@@ -268,27 +173,21 @@
import static org.onosproject.yangutils.utils.UtilConstants.PROTECTED;
import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
import static org.onosproject.yangutils.utils.UtilConstants.RETURN;
+import static org.onosproject.yangutils.utils.UtilConstants.SCHEMA_NAME;
import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
-import static org.onosproject.yangutils.utils.UtilConstants
- .SERVICE_METHOD_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_METHOD_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE;
import static org.onosproject.yangutils.utils.UtilConstants.TO;
-import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType
- .GETTER_METHOD;
-import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType
- .TYPE_CONSTRUCTOR;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils
- .getCapitalCase;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils
- .insertDataIntoJavaFile;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.replaceLast;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils
- .validateLineLength;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen
- .getYangAugmentedMapObjectForConstruct;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.validateLineLength;
+
import static java.util.Collections.sort;
/**
@@ -908,10 +807,6 @@
List<YangType<?>> types = typeDef.getTypeList();
YangType type = types.get(0);
YangDataTypes yangDataTypes = type.getDataType();
- if (type.getDataType().equals(BINARY)) {
- imports.add(IMPORT + JAVA_UTIL_OBJECTS_IMPORT_PKG + PERIOD +
- JAVA_UTIL_IMPORT_BASE64_CLASS);
- }
initiateJavaFileGeneration(file, className, GENERATE_TYPEDEF_CLASS,
imports, path, pluginConfig);
@@ -1343,27 +1238,21 @@
insertDataIntoJavaFile(file,
getJavaDoc(TYPE_CONSTRUCTOR, className, false,
pluginConfig, null)
- + getEnumsConstructor(
- getCapitalCase(className)) + NEW_LINE);
+ + getEnumsConstructor(getCapitalCase(className)) + NEW_LINE);
- TempJavaEnumerationFragmentFiles enumFragFiles =
- ((TempJavaCodeFragmentFilesContainer) curNode)
- .getTempJavaCodeFragmentFiles()
- .getEnumerationTempFiles();
insertDataIntoJavaFile(file,
- getEnumsOfMethod(className, enumFragFiles
- .getJavaAttributeForEnum(
- pluginConfig),
- enumFragFiles
- .getEnumSetJavaMap(),
- enumFragFiles
- .getEnumStringList(),
- pluginConfig) + NEW_LINE);
+ getEnumsOfValueMethod(className, (YangEnumeration) curNode, pluginConfig) + NEW_LINE);
+ insertDataIntoJavaFile(file,
+ getEnumValueOfSchemaNameMethod(className, pluginConfig, (YangEnumeration) curNode));
// Add a getter method for enum.
insertDataIntoJavaFile(file, getJavaDoc(GETTER_METHOD, className, false,
pluginConfig, null) +
getGetter(INT, className, GENERATE_ENUM_CLASS) + NEW_LINE);
+ insertDataIntoJavaFile(file, getJavaDoc(GETTER_METHOD, SCHEMA_NAME, false,
+ pluginConfig, null) +
+ getGetter(STRING_DATA_TYPE, SCHEMA_NAME,
+ GENERATE_ENUM_CLASS) + NEW_LINE);
try {
insertDataIntoJavaFile(file, getFromStringMethodSignature(
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
index 93e26c7..b77a158 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
@@ -95,6 +95,7 @@
return pkg.toLowerCase();
}
+
/**
* Returns version.
*
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
index d044456..5b38096 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
@@ -17,10 +17,11 @@
package org.onosproject.yangutils.translator.tojava.utils;
import java.util.List;
-import java.util.Map;
import org.onosproject.yangutils.datamodel.YangAtomicPath;
import org.onosproject.yangutils.datamodel.YangCompilerAnnotation;
+import org.onosproject.yangutils.datamodel.YangEnum;
+import org.onosproject.yangutils.datamodel.YangEnumeration;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
@@ -45,9 +46,11 @@
import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT8;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getAugmentedClassNameForDataMethods;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils
+ .getAugmentedClassNameForDataMethods;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getParentNodeNameForDataMethods;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getSetOfNodeIdentifiers;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute;
import static org.onosproject.yangutils.translator.tojava.utils.ValidatorTypeForUnionTypes.INT_TYPE_CONFLICT;
import static org.onosproject.yangutils.translator.tojava.utils.ValidatorTypeForUnionTypes.SHORT_TYPE_CONFLICT;
import static org.onosproject.yangutils.utils.UtilConstants.ADD;
@@ -143,6 +146,7 @@
import static org.onosproject.yangutils.utils.UtilConstants.REPLACE_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.RETURN;
import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME;
+import static org.onosproject.yangutils.utils.UtilConstants.SCHEMA_NAME;
import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
import static org.onosproject.yangutils.utils.UtilConstants.SET;
import static org.onosproject.yangutils.utils.UtilConstants.SET_METHOD_PREFIX;
@@ -158,6 +162,7 @@
import static org.onosproject.yangutils.utils.UtilConstants.SQUARE_BRACKETS;
import static org.onosproject.yangutils.utils.UtilConstants.STATIC;
import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE;
+import static org.onosproject.yangutils.utils.UtilConstants.STR_VAL;
import static org.onosproject.yangutils.utils.UtilConstants.SUFFIX_S;
import static org.onosproject.yangutils.utils.UtilConstants.SWITCH;
import static org.onosproject.yangutils.utils.UtilConstants.THIS;
@@ -244,12 +249,12 @@
if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) {
return generateForGetMethodWithAttribute(returnType)
+ getGetterForInterface(attributeName, returnType, attr.isListAttr(), generatedJavaFiles,
- attr.getCompilerAnnotation());
+ attr.getCompilerAnnotation());
}
return getJavaDoc(GETTER_METHOD, attributeName, attr.isListAttr(), pluginConfig, appDataStructure)
+ getGetterForInterface(attributeName, returnType, attr.isListAttr(), generatedJavaFiles,
- attr.getCompilerAnnotation());
+ attr.getCompilerAnnotation());
}
/**
@@ -279,7 +284,7 @@
}
return getJavaDoc(type, attributeName, attr.isListAttr(), pluginConfig, appDataStructure)
+ getSetterForInterface(attributeName, attrType, className, attr.isListAttr(), generatedJavaFiles,
- attr.getCompilerAnnotation());
+ attr.getCompilerAnnotation());
}
/**
@@ -926,7 +931,7 @@
+ FROM_STRING_PARAM_NAME + CLOSE_PARENTHESIS + SEMI_COLAN;
} else {
String parseFromStringMethod = getParseFromStringMethod(targetDataType,
- fromStringAttributeInfo.getAttributeType());
+ fromStringAttributeInfo.getAttributeType());
return targetDataType + SPACE + TMP_VAL + SPACE + EQUAL + SPACE + parseFromStringMethod
+ OPEN_PARENTHESIS + FROM_STRING_PARAM_NAME + CLOSE_PARENTHESIS + SEMI_COLAN;
}
@@ -1130,8 +1135,9 @@
appDataStructure = attr1.getCompilerAnnotation().getYangAppDataStructure().getDataStructure().name();
}
return getJavaDoc(TYPE_CONSTRUCTOR, generatedJavaClassName + " for type " + attrName1, false, pluginConfig,
- appDataStructure) + getTypeConstructorString(attrType, attrName1,
- attrName2, generatedJavaClassName, type, addFirst);
+ appDataStructure) + getTypeConstructorString(attrType, attrName1,
+ attrName2, generatedJavaClassName, type,
+ addFirst);
}
/**
@@ -1273,36 +1279,34 @@
* @return enum's constructor
*/
static String getEnumsConstructor(String className) {
- return FOUR_SPACE_INDENTATION + className + OPEN_PARENTHESIS + INT + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE
+ return FOUR_SPACE_INDENTATION + className + OPEN_PARENTHESIS + INT + SPACE + VALUE +
+ COMMA + SPACE + STRING_DATA_TYPE + SPACE + STR_VAL + CLOSE_PARENTHESIS + SPACE
+ OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + getSmallCase(className) + SPACE + EQUAL
- + SPACE + VALUE + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
+ + SPACE + VALUE + SEMI_COLAN + NEW_LINE
+ + EIGHT_SPACE_INDENTATION + SCHEMA_NAME + SPACE + EQUAL
+ + SPACE + STR_VAL + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
}
/**
* Returns of method for enum class.
*
* @param className class name
- * @param attr java attribute
- * @param enumMap enum's sets map
- * @param enumList enum's sets list
* @param pluginConfig plugin configurations
* @return of method
*/
- static String getEnumsOfMethod(String className, JavaAttributeInfo attr,
- Map<String, Integer> enumMap, List<String> enumList,
- YangPluginConfig pluginConfig) {
- String attrType = getReturnType(attr);
- String attrName = attr.getAttributeName();
+ static String getEnumsOfValueMethod(String className, YangEnumeration enumeration,
+ YangPluginConfig pluginConfig) {
String method = FOUR_SPACE_INDENTATION + PUBLIC + SPACE + STATIC + SPACE + getCapitalCase(className) + SPACE
+ OF + OPEN_PARENTHESIS
- + attrType + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE
+ + INT + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE
+ EIGHT_SPACE_INDENTATION + SWITCH + SPACE + OPEN_PARENTHESIS + VALUE
+ CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
int value;
- for (String str : enumList) {
-
- value = enumMap.get(str);
+ String str;
+ for (YangEnum yangEnum : enumeration.getEnumSet()) {
+ value = yangEnum.getValue();
+ str = getEnumJavaAttribute(yangEnum.getNamedValue()).toUpperCase();
method = method + TWELVE_SPACE_INDENTATION + CASE + SPACE + value + COLON + NEW_LINE
+ SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + getCapitalCase(className) + PERIOD
+ str + SEMI_COLAN + NEW_LINE;
@@ -1311,7 +1315,39 @@
+ RETURN + SPACE + NULL + SEMI_COLAN + NEW_LINE + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET
+ NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
- return getJavaDoc(OF_METHOD, getCapitalCase(className) + " for type " + attrName, false, pluginConfig, null)
+ return getJavaDoc(OF_METHOD, getCapitalCase(className) + " for value", false, pluginConfig, null)
+ + method;
+ }
+
+ /**
+ * Returns of method with string value for enum class.
+ *
+ * @param enumName enum class name
+ * @return of method with string value for enum class
+ */
+ static String getEnumValueOfSchemaNameMethod(String enumName,
+ YangPluginConfig pluginConfig,
+ YangEnumeration enumeration) {
+
+ String method = FOUR_SPACE_INDENTATION + PUBLIC + SPACE + STATIC + SPACE + getCapitalCase(enumName) + SPACE
+ + OF + OPEN_PARENTHESIS
+ + STRING_DATA_TYPE + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE
+ + EIGHT_SPACE_INDENTATION + SWITCH + SPACE + OPEN_PARENTHESIS + VALUE
+ + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
+ String value;
+ for (YangEnum yangEnum : enumeration.getEnumSet()) {
+
+ value = getEnumJavaAttribute(yangEnum.getNamedValue()).toUpperCase();
+ method = method + TWELVE_SPACE_INDENTATION + CASE + SPACE + QUOTES +
+ yangEnum.getNamedValue() + QUOTES + COLON + NEW_LINE
+ + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + getCapitalCase(enumName) + PERIOD
+ + value + SEMI_COLAN + NEW_LINE;
+ }
+ method = method + TWELVE_SPACE_INDENTATION + DEFAULT + SPACE + COLON + NEW_LINE + SIXTEEN_SPACE_INDENTATION
+ + RETURN + SPACE + NULL + SEMI_COLAN + NEW_LINE + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET
+ + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
+
+ return getJavaDoc(OF_METHOD, getCapitalCase(enumName) + " for " + SCHEMA_NAME, false, pluginConfig, null)
+ method;
}
@@ -1357,10 +1393,10 @@
return targetDataType + PERIOD + FROM_STRING_METHOD_NAME;
default:
throw new TranslatorException("given data type is not supported. " +
- yangType.getDataTypeName() + " in " +
- yangType.getLineNumber() + " at " +
- yangType.getCharPosition()
- + " in " + yangType.getFileName());
+ yangType.getDataTypeName() + " in " +
+ yangType.getLineNumber() + " at " +
+ yangType.getCharPosition()
+ + " in " + yangType.getFileName());
}
}
@@ -1399,8 +1435,8 @@
method = getJavaDoc(MANAGER_SETTER_METHOD, AUGMENTED +
getCapitalCase(parentName) + getCapitalCase(curNodeName), false, pluginConfig, null) +
getSetterForInterface(getSmallCase(AUGMENTED) + parentName +
- getCapitalCase(curNodeName), returnType, parentName, false,
- GENERATE_SERVICE_AND_MANAGER, null) + NEW_LINE;
+ getCapitalCase(curNodeName), returnType, parentName, false,
+ GENERATE_SERVICE_AND_MANAGER, null) + NEW_LINE;
methods.append(method);
}
return methods.toString();
diff --git a/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java b/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
index 8b323bc..5de5b1c 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
@@ -302,6 +302,21 @@
public static final String SPACE = " ";
/**
+ * Static attribute for schema name.
+ */
+ public static final String SCHEMA_NAME = "schemaName";
+
+ /**
+ * Static attribute for schema name value.
+ */
+ public static final String STR_VAL = "stringValue";
+
+ /**
+ * Static attribute for value of method.
+ */
+ public static final String VALUE_OF = "valueOf";
+
+ /**
* Static attribute for validateRange.
*/
public static final String VALIDATE_RANGE = "validateRange";
diff --git a/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java b/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
index 341d6d6..a5e86d1 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
@@ -188,6 +188,17 @@
* @return javaDocs
*/
private static String generateForEnumAttr(String name) {
+ return FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + ENUM_ATTRIBUTE_JAVADOC
+ + name + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE;
+ }
+
+ /**
+ * Generates javaDocs for inner class enum's attributes.
+ *
+ * @param name attribute name
+ * @return javaDocs
+ */
+ public static String enumJavaDocForInnerClass(String name) {
return EIGHT_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + EIGHT_SPACE_INDENTATION + ENUM_ATTRIBUTE_JAVADOC
+ name + PERIOD + NEW_LINE + EIGHT_SPACE_INDENTATION + JAVA_DOC_END_LINE;
}