Optimizing Generate Code Function in Translator and updating enum/union to support a special hierarchical scenario
Change-Id: I14a971ff6fcda6ae5e86ffe4c11d17a844e371ce
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEnumeration.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEnumeration.java
index 469809c..f004d5e 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEnumeration.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEnumeration.java
@@ -31,18 +31,19 @@
/**
* Represents the enumeration data type information.
*/
-public class YangEnumeration implements Parsable {
+public class YangEnumeration extends YangNode implements Parsable {
// Enumeration info set.
private Set<YangEnum> enumSet;
// Enumeration name.
- private String enumerationName;
+ private String name;
/**
* Creates an enumeration object.
*/
public YangEnumeration() {
+ super(YangNodeType.ENUMERATION_NODE);
setEnumSet(new HashSet<YangEnum>());
}
@@ -77,21 +78,23 @@
}
/**
- * Return enumeration name.
+ * Returns enumeration name.
*
* @return the enumeration name
*/
- public String getEnumerationName() {
- return enumerationName;
+ @Override
+ public String getName() {
+ return name;
}
/**
* Sets the enumeration name.
*
- * @param enumerationName enumeration name
+ * @param name enumeration name
*/
- public void setEnumerationName(String enumerationName) {
- this.enumerationName = enumerationName;
+ @Override
+ public void setName(String name) {
+ this.name = name;
}
/**
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangNodeType.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangNodeType.java
index 174ca39..35fe918 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangNodeType.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangNodeType.java
@@ -95,6 +95,11 @@
RPC_NODE,
/**
+ * Node contains "YANG's union" information.
+ */
+ UNION_NODE,
+
+ /**
* Node contains "YANG's list" information.
*/
LIST_NODE
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUnion.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUnion.java
index 5170871..21aabc0 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUnion.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUnion.java
@@ -16,13 +16,13 @@
package org.onosproject.yangutils.datamodel;
-import java.util.LinkedList;
-import java.util.List;
-
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.utils.YangConstructType;
+import java.util.LinkedList;
+import java.util.List;
+
/*
* Reference RFC 6020.
*
@@ -48,19 +48,24 @@
/**
* Represents data model node to maintain information defined in YANG union.
*/
-public class YangUnion implements Parsable {
+public class YangUnion extends YangNode implements Parsable {
// List of YANG type.
private List<YangType<?>> typeList;
// Name of union.
- private String unionName;
+ private String name;
+
+ // Current child union number.
+ private int childUnionNumber;
/**
* Creates a YANG union node.
*/
public YangUnion() {
+ super(YangNodeType.UNION_NODE);
typeList = new LinkedList<>();
+ childUnionNumber = 1;
}
/**
@@ -73,15 +78,6 @@
}
/**
- * Returns union name.
- *
- * @return the union name
- */
- public String getUnionName() {
- return unionName;
- }
-
- /**
* Sets the list of YANG type.
*
* @param typeList list of YANG type.
@@ -91,13 +87,31 @@
}
/**
- * Adds YANG type to type list.
+ * Returns running child union number.
+ *
+ * @return running child union number
+ */
+ public int getChildUnionNumber() {
+ return childUnionNumber;
+ }
+
+ /**
+ * Sets the running child union number.
+ *
+ * @param childUnionNumber running child union number
+ */
+ public void setChildUnionNumber(int childUnionNumber) {
+ this.childUnionNumber = childUnionNumber;
+ }
+
+ /**
+ * Add YANG type to type list.
*
* @param yangType YANG type to be added to list
* @throws DataModelException union member type must not be one of the
* built-in types "empty" or "leafref"
*/
- public void addToTypeList(YangType<?> yangType) throws DataModelException {
+ public void addType(YangType<?> yangType) throws DataModelException {
if (yangType.getDataType() == YangDataTypes.EMPTY || yangType.getDataType() == YangDataTypes.LEAFREF) {
throw new DataModelException("Union member type must not be one of the built-in types \"empty\" or " +
"\"leafref\"");
@@ -106,12 +120,23 @@
}
/**
+ * Returns union name.
+ *
+ * @return the union name
+ */
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ /**
* Sets the union name.
*
- * @param unionName name of the union.
+ * @param name union name
*/
- public void setUnionName(String unionName) {
- this.unionName = unionName;
+ @Override
+ public void setName(String name) {
+ this.name = name;
}
@Override
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/EnumerationListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/EnumerationListener.java
index 9bca04d..c1703c8 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/EnumerationListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/EnumerationListener.java
@@ -44,19 +44,25 @@
import org.onosproject.yangutils.datamodel.YangEnumeration;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangType;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
import org.onosproject.yangutils.datamodel.YangUnion;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
+import org.onosproject.yangutils.utils.YangConstructType;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
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_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.utils.YangConstructType.ENUMERATION_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
@@ -69,6 +75,11 @@
public final class EnumerationListener {
/**
+ * Suffix to be used while creating enumeration class.
+ */
+ private static final String ENUMERATION_CLASS_SUFFIX = "_enum";
+
+ /**
* Creates a new enumeration listener.
*/
private EnumerationListener() {
@@ -98,15 +109,48 @@
switch (tmpData.getYangConstructType()) {
case LEAF_DATA:
- enumerationNode.setEnumerationName(((YangLeaf) tmpData).getLeafName());
+ // Set the name of enumeration same as leaf.
+ enumerationNode.setName(((YangLeaf) tmpData).getLeafName() + ENUMERATION_CLASS_SUFFIX);
+ // Pop the stack entry to obtain the parent YANG node.
+ Parsable leaf = listener.getParsedDataStack().pop();
+ // Add the enumeration node to the parent holder of leaf.
+ addChildToParentNode(listener, enumerationNode);
+ // Push the popped entry back to the stack.
+ listener.getParsedDataStack().push(leaf);
break;
case LEAF_LIST_DATA:
- enumerationNode.setEnumerationName(((YangLeafList) tmpData).getLeafName());
+ // Set the name of enumeration same as leaf list.
+ enumerationNode.setName(((YangLeafList) tmpData).getLeafName() + ENUMERATION_CLASS_SUFFIX);
+ // Pop the stack entry to obtain the parent YANG node.
+ Parsable leafList = listener.getParsedDataStack().pop();
+ // Add the enumeration node to the parent holder of leaf.
+ addChildToParentNode(listener, enumerationNode);
+ // Push the popped entry back to the stack.
+ listener.getParsedDataStack().push(leafList);
break;
case UNION_DATA:
- enumerationNode.setEnumerationName(((YangUnion) tmpData).getUnionName());
+ YangUnion yangUnion = (YangUnion) tmpData;
+ /*
+ * In case parent of enumeration is a union, name of the
+ * enumeration is parent union name suffixed with running
+ * integer number, this is done because under union there
+ * could be multiple child union types.
+ */
+ enumerationNode.setName(yangUnion.getName() + yangUnion.getChildUnionNumber()
+ + ENUMERATION_CLASS_SUFFIX);
+ // Increment the running number.
+ yangUnion.setChildUnionNumber(yangUnion.getChildUnionNumber() + 1);
+ // Add union as a child to parent union.
+ addChildToParentNode(listener, enumerationNode);
break;
- // TODO typedef, deviate.
+ case TYPEDEF_DATA:
+ YangTypeDef typeDef = (YangTypeDef) tmpData;
+ // Set the name of enumeration same as typedef name.
+ enumerationNode.setName(typeDef.getName() + ENUMERATION_CLASS_SUFFIX);
+ // Add enumeration as a child to parent type def.
+ addChildToParentNode(listener, enumerationNode);
+ break;
+ // TODO deviate.
default:
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, TYPE_DATA,
((YangType<?>) typeData).getDataTypeName(), ENTRY));
@@ -155,4 +199,25 @@
constructListenerErrorMessage(MISSING_CURRENT_HOLDER, ENUMERATION_DATA, "", EXIT));
}
}
+
+ /**
+ * Adds the enumeration node to the parent holder.
+ *
+ * @param listener listener's object
+ * @param enumerationNode enumeration node which needs to be added to parent
+ */
+ private static void addChildToParentNode(TreeWalkListener listener, YangEnumeration enumerationNode) {
+ if (!(listener.getParsedDataStack().peek() instanceof YangNode)) {
+ throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, ENUMERATION_DATA,
+ "", ENTRY));
+ } else {
+ YangNode curNode = (YangNode) listener.getParsedDataStack().peek();
+ try {
+ curNode.addChild(enumerationNode);
+ } catch (DataModelException e) {
+ throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
+ YangConstructType.ENUMERATION_DATA, "", ENTRY, e.getMessage()));
+ }
+ }
+ }
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java
index c953be5..67f2299 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java
@@ -204,7 +204,7 @@
case UNION_DATA:
YangUnion unionNode = (YangUnion) tmpData;
try {
- unionNode.addToTypeList((YangType<?>) type);
+ unionNode.addType((YangType<?>) type);
} catch (DataModelException e) {
ParserException parserException = new ParserException(e.getMessage());
parserException.setLine(ctx.getStart().getLine());
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/UnionListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/UnionListener.java
index 79ce0b9..5eeaa07 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/UnionListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/UnionListener.java
@@ -42,19 +42,25 @@
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangType;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
import org.onosproject.yangutils.datamodel.YangUnion;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
+import org.onosproject.yangutils.utils.YangConstructType;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
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_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.UNION_DATA;
@@ -66,6 +72,11 @@
public final class UnionListener {
/**
+ * Suffix to be used while creating union class.
+ */
+ private static final String UNION_CLASS_SUFFIX = "_union";
+
+ /**
* Creates a new union listener.
*/
private UnionListener() {
@@ -95,15 +106,47 @@
switch (tmpData.getYangConstructType()) {
case LEAF_DATA:
- unionNode.setUnionName(((YangLeaf) tmpData).getLeafName());
+ // Set the name of union same as leaf.
+ unionNode.setName(((YangLeaf) tmpData).getLeafName() + UNION_CLASS_SUFFIX);
+ // Pop the stack entry to obtain the parent YANG node.
+ Parsable leaf = listener.getParsedDataStack().pop();
+ // Add the union node to the parent holder of leaf.
+ addChildToParentNode(listener, unionNode);
+ // Push the popped entry back to the stack.
+ listener.getParsedDataStack().push(leaf);
break;
case LEAF_LIST_DATA:
- unionNode.setUnionName(((YangLeafList) tmpData).getLeafName());
+ // Set the name of union same as leaf list.
+ unionNode.setName(((YangLeafList) tmpData).getLeafName() + UNION_CLASS_SUFFIX);
+ // Pop the stack entry to obtain the parent YANG node.
+ Parsable leafList = listener.getParsedDataStack().pop();
+ // Add the union node to the parent holder of leaf.
+ addChildToParentNode(listener, unionNode);
+ // Push the popped entry back to the stack.
+ listener.getParsedDataStack().push(leafList);
break;
case UNION_DATA:
- unionNode.setUnionName(((YangUnion) tmpData).getUnionName());
+ YangUnion parentUnion = (YangUnion) tmpData;
+ /*
+ * In case parent of union is again a union, name of the
+ * child union is parent union name suffixed with running
+ * integer number, this is done because under union there
+ * could be multiple child union types.
+ */
+ unionNode.setName(parentUnion.getName() + UNION_CLASS_SUFFIX + parentUnion.getChildUnionNumber());
+ // Increment the running number.
+ parentUnion.setChildUnionNumber(parentUnion.getChildUnionNumber() + 1);
+ // Add union as a child to parent union.
+ addChildToParentNode(listener, unionNode);
break;
- // TODO typedef, deviate.
+ case TYPEDEF_DATA:
+ YangTypeDef typeDef = (YangTypeDef) tmpData;
+ // Set the name of union same as typedef name.
+ unionNode.setName(typeDef.getName() + UNION_CLASS_SUFFIX);
+ // Add union as a child to parent type def.
+ addChildToParentNode(listener, unionNode);
+ break;
+ // TODO deviate.
default:
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, TYPE_DATA,
((YangType<?>) typeData).getDataTypeName(), ENTRY));
@@ -152,4 +195,25 @@
constructListenerErrorMessage(MISSING_CURRENT_HOLDER, UNION_DATA, "", EXIT));
}
}
+
+ /**
+ * Adds the union node to the parent holder.
+ *
+ * @param listener listener's object
+ * @param unionNode union node which needs to be added to parent
+ */
+ private static void addChildToParentNode(TreeWalkListener listener, YangUnion unionNode) {
+ if (!(listener.getParsedDataStack().peek() instanceof YangNode)) {
+ throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, UNION_DATA,
+ "", ENTRY));
+ } else {
+ YangNode curNode = (YangNode) listener.getParsedDataStack().peek();
+ try {
+ curNode.addChild(unionNode);
+ } catch (DataModelException e) {
+ throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
+ YangConstructType.UNION_DATA, "", ENTRY, e.getMessage()));
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/JavaCodeGeneratorInfo.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/JavaCodeGeneratorInfo.java
new file mode 100644
index 0000000..5335ff4
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/JavaCodeGeneratorInfo.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.translator.tojava.javamodel;
+
+import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
+import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
+
+/**
+ * Represents YANG java info containing interface for java code generator, java
+ * file information, java import data and temp java code fragment files. This
+ * interface serves as a generic interface and help to unify the generate code
+ * entry function.
+ */
+public interface JavaCodeGeneratorInfo extends HasJavaFileInfo, HasTempJavaCodeFragmentFiles, HasJavaImportData {
+}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaAugment.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaAugment.java
index ee1ad27..7cf50f3 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaAugment.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaAugment.java
@@ -16,30 +16,20 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
-
import org.onosproject.yangutils.datamodel.YangAugment;
import org.onosproject.yangutils.translator.exception.TranslatorException;
-import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
-import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
-import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
+import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
/**
* Represents augment information extended to support java code generation.
*/
-public class YangJavaAugment extends YangAugment
- implements JavaCodeGenerator, HasJavaFileInfo,
- HasJavaImportData, HasTempJavaCodeFragmentFiles {
+public class YangJavaAugment extends YangAugment implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains the information of the java file being generated.
@@ -142,28 +132,11 @@
*/
@Override
public void generateCodeEntry(String codeGenDir) throws IOException {
-
- getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
- getJavaFileInfo().setPackage(getCurNodePackage(this));
- getJavaFileInfo().setPackageFilePath(
- getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
- getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
-
- String absloutePath = getAbsolutePackagePath(
- getJavaFileInfo().getBaseCodeGenPath(),
- getJavaFileInfo().getPackageFilePath());
-
- setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(
- getJavaFileInfo().getGeneratedFileTypes(), absloutePath,
- getJavaFileInfo().getJavaName()));
-
- getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
-
- getTempJavaCodeFragmentFiles().addCurNodeInfoInParentTempFile(this, false);
+ generateCodeOfNode(this, codeGenDir, false);
}
/**
- * Create a java file using the YANG grouping info.
+ * Creates a java file using the YANG grouping info.
*/
@Override
public void generateCodeExit() {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaCase.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaCase.java
index 113e133..f9038f5 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaCase.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaCase.java
@@ -16,30 +16,20 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
-
import org.onosproject.yangutils.datamodel.YangCase;
import org.onosproject.yangutils.translator.exception.TranslatorException;
-import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
-import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
-import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
+import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
/**
* Represents case information extended to support java code generation.
*/
-public class YangJavaCase extends YangCase
- implements JavaCodeGenerator, HasJavaFileInfo,
- HasJavaImportData, HasTempJavaCodeFragmentFiles {
+public class YangJavaCase extends YangCase implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains the information of the java file being generated.
@@ -75,7 +65,6 @@
*/
@Override
public JavaFileInfo getJavaFileInfo() {
-
if (javaFileInfo == null) {
throw new TranslatorException("Missing java info in java datamodel node");
}
@@ -142,28 +131,11 @@
*/
@Override
public void generateCodeEntry(String codeGenDir) throws IOException {
-
- getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
- getJavaFileInfo().setPackage(getCurNodePackage(this));
- getJavaFileInfo().setPackageFilePath(
- getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
- getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
-
- String absloutePath = getAbsolutePackagePath(
- getJavaFileInfo().getBaseCodeGenPath(),
- getJavaFileInfo().getPackageFilePath());
-
- setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(
- getJavaFileInfo().getGeneratedFileTypes(), absloutePath,
- getJavaFileInfo().getJavaName()));
-
- getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
-
- getTempJavaCodeFragmentFiles().addCurNodeInfoInParentTempFile(this, false);
+ generateCodeOfNode(this, codeGenDir, false);
}
/**
- * Create a java file using the YANG grouping info.
+ * Creates a java file using the YANG grouping info.
*/
@Override
public void generateCodeExit() {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaChoice.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaChoice.java
index 4cec959..d550815 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaChoice.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaChoice.java
@@ -16,30 +16,20 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
-
import org.onosproject.yangutils.datamodel.YangChoice;
import org.onosproject.yangutils.translator.exception.TranslatorException;
-import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
-import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
-import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
+import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
/**
* Represents choice information extended to support java code generation.
*/
-public class YangJavaChoice extends YangChoice
- implements JavaCodeGenerator, HasJavaFileInfo,
- HasJavaImportData, HasTempJavaCodeFragmentFiles {
+public class YangJavaChoice extends YangChoice implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains the information of the java file being generated.
@@ -75,7 +65,6 @@
*/
@Override
public JavaFileInfo getJavaFileInfo() {
-
if (javaFileInfo == null) {
throw new TranslatorException("Missing java info in java datamodel node");
}
@@ -142,28 +131,12 @@
*/
@Override
public void generateCodeEntry(String codeGenDir) throws IOException {
-
- getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
- getJavaFileInfo().setPackage(getCurNodePackage(this));
- getJavaFileInfo().setPackageFilePath(
- getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
- getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
-
- String absloutePath = getAbsolutePackagePath(
- getJavaFileInfo().getBaseCodeGenPath(),
- getJavaFileInfo().getPackageFilePath());
-
- setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(
- getJavaFileInfo().getGeneratedFileTypes(), absloutePath,
- getJavaFileInfo().getJavaName()));
-
- // TODO:getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
-
- getTempJavaCodeFragmentFiles().addCurNodeInfoInParentTempFile(this, false);
+ generateCodeOfNode(this, codeGenDir, false);
+ // TODO:getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
}
/**
- * Create a java file using the YANG grouping info.
+ * Creates a java file using the YANG grouping info.
*/
@Override
public void generateCodeExit() {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaContainer.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaContainer.java
index e045c89..dabac6b 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaContainer.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaContainer.java
@@ -16,30 +16,20 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
-
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.translator.exception.TranslatorException;
-import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
-import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
-import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
+import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
/**
* Represents container information extended to support java code generation.
*/
-public class YangJavaContainer extends YangContainer
- implements JavaCodeGenerator, HasJavaFileInfo,
- HasJavaImportData, HasTempJavaCodeFragmentFiles {
+public class YangJavaContainer extends YangContainer implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains the information of the java file being generated.
@@ -75,7 +65,6 @@
*/
@Override
public JavaFileInfo getJavaFileInfo() {
-
if (javaFileInfo == null) {
throw new TranslatorException("Missing java info in java datamodel node");
}
@@ -142,28 +131,11 @@
*/
@Override
public void generateCodeEntry(String codeGenDir) throws IOException {
-
- getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
- getJavaFileInfo().setPackage(getCurNodePackage(this));
- getJavaFileInfo().setPackageFilePath(
- getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
- getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
-
- String absloutePath = getAbsolutePackagePath(
- getJavaFileInfo().getBaseCodeGenPath(),
- getJavaFileInfo().getPackageFilePath());
-
- setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(
- getJavaFileInfo().getGeneratedFileTypes(), absloutePath,
- getJavaFileInfo().getJavaName()));
-
- getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
-
- getTempJavaCodeFragmentFiles().addCurNodeInfoInParentTempFile(this, false);
+ generateCodeOfNode(this, codeGenDir, false);
}
/**
- * Create a java file using the YANG grouping info.
+ * Create a java file using the YANG container info.
*
* @throws IOException IO operation fail
*/
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaGrouping.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaGrouping.java
index d8b7c6e..05d13be 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaGrouping.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaGrouping.java
@@ -16,30 +16,20 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
-
import org.onosproject.yangutils.datamodel.YangGrouping;
import org.onosproject.yangutils.translator.exception.TranslatorException;
-import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
-import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
-import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
+import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
/**
* Represents grouping information extended to support java code generation.
*/
-public class YangJavaGrouping extends YangGrouping
- implements JavaCodeGenerator, HasJavaFileInfo,
- HasJavaImportData, HasTempJavaCodeFragmentFiles {
+public class YangJavaGrouping extends YangGrouping implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains the information of the java file being generated.
@@ -75,7 +65,6 @@
*/
@Override
public JavaFileInfo getJavaFileInfo() {
-
if (javaFileInfo == null) {
throw new TranslatorException("Missing java info in java datamodel node");
}
@@ -142,28 +131,11 @@
*/
@Override
public void generateCodeEntry(String codeGenDir) throws IOException {
-
- getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
- getJavaFileInfo().setPackage(getCurNodePackage(this));
- getJavaFileInfo().setPackageFilePath(
- getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
- getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
-
- String absloutePath = getAbsolutePackagePath(
- getJavaFileInfo().getBaseCodeGenPath(),
- getJavaFileInfo().getPackageFilePath());
-
- setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(
- getJavaFileInfo().getGeneratedFileTypes(), absloutePath,
- getJavaFileInfo().getJavaName()));
-
- getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
-
- getTempJavaCodeFragmentFiles().addCurNodeInfoInParentTempFile(this, false);
+ generateCodeOfNode(this, codeGenDir, false);
}
/**
- * Create a java file using the YANG grouping info.
+ * Creates a java file using the YANG grouping info.
*/
@Override
public void generateCodeExit() {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaInput.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaInput.java
index 5a935da..f2f01d7 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaInput.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaInput.java
@@ -17,31 +17,20 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
-
import org.onosproject.yangutils.datamodel.YangInput;
import org.onosproject.yangutils.translator.exception.TranslatorException;
-import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
-import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
-import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
-import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
+import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
/**
* Represents input information extended to support java code generation.
*/
-public class YangJavaInput extends YangInput
- implements JavaCodeGenerator, HasJavaFileInfo,
- HasJavaImportData, HasTempJavaCodeFragmentFiles {
+public class YangJavaInput extends YangInput implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains information of the java file being generated.
@@ -77,7 +66,6 @@
*/
@Override
public JavaFileInfo getJavaFileInfo() {
-
if (javaFileInfo == null) {
throw new TranslatorException("Missing java info in java datamodel node");
}
@@ -144,28 +132,11 @@
*/
@Override
public void generateCodeEntry(String codeGenDir) throws IOException {
-
- getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
- getJavaFileInfo().setPackage(getCurNodePackage(this));
- getJavaFileInfo().setPackageFilePath(
- getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
- getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
-
- String absloutePath = getAbsolutePackagePath(
- getJavaFileInfo().getBaseCodeGenPath(),
- getJavaFileInfo().getPackageFilePath());
- createPackage(absloutePath, getName());
- setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(
- getJavaFileInfo().getGeneratedFileTypes(), absloutePath,
- getJavaFileInfo().getJavaName()));
-
- getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
-
- getTempJavaCodeFragmentFiles().addCurNodeInfoInParentTempFile(this, false);
+ generateCodeOfNode(this, codeGenDir, false);
}
/**
- * Create a java file using the YANG grouping info.
+ * Creates a java file using the YANG grouping info.
*
* @throws IOException IO operation fail
*/
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaList.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaList.java
index 6886990..8e84716 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaList.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaList.java
@@ -16,31 +16,20 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
-
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.translator.exception.TranslatorException;
-import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
-import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
-import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
-import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
+import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
/**
- * Represents YANG List information extended to support java code generation.
+ * Represents YANG list information extended to support java code generation.
*/
-public class YangJavaList extends YangList
- implements JavaCodeGenerator, HasJavaFileInfo,
- HasJavaImportData, HasTempJavaCodeFragmentFiles {
+public class YangJavaList extends YangList implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains the information of the java file being generated.
@@ -76,7 +65,6 @@
*/
@Override
public JavaFileInfo getJavaFileInfo() {
-
if (javaFileInfo == null) {
throw new TranslatorException("Missing java info in java datamodel node");
}
@@ -143,30 +131,11 @@
*/
@Override
public void generateCodeEntry(String codeGenDir) throws IOException {
-
- getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
- getJavaFileInfo().setPackage(getCurNodePackage(this));
-
- getJavaFileInfo().setPackageFilePath(
- getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
- getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
-
- String absloutePath = getAbsolutePackagePath(
- getJavaFileInfo().getBaseCodeGenPath(),
- getJavaFileInfo().getPackageFilePath());
- createPackage(absloutePath, getName());
-
- setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(
- getJavaFileInfo().getGeneratedFileTypes(), absloutePath,
- getJavaFileInfo().getJavaName()));
-
- getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
-
- getTempJavaCodeFragmentFiles().addCurNodeInfoInParentTempFile(this, true);
+ generateCodeOfNode(this, codeGenDir, true);
}
/**
- * Create a java file using the YANG grouping info.
+ * Creates a java file using the YANG grouping info.
*
* @throws IOException IO operation fail
*/
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java
index 9b53391..235ebc5 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java
@@ -16,30 +16,21 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
-
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.translator.exception.TranslatorException;
-import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
-import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
-import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
+import org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
/**
* Represents module information extended to support java code generation.
*/
-public class YangJavaModule extends YangModule
- implements JavaCodeGenerator, HasJavaFileInfo,
- HasJavaImportData, HasTempJavaCodeFragmentFiles {
+public class YangJavaModule extends YangModule implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains the information of the java file being generated.
@@ -59,7 +50,7 @@
private TempJavaCodeFragmentFiles tempFileHandle;
/**
- * Create a YANG node of module type.
+ * Creates a YANG node of module type.
*/
public YangJavaModule() {
super();
@@ -75,7 +66,6 @@
*/
@Override
public JavaFileInfo getJavaFileInfo() {
-
if (javaFileInfo == null) {
throw new TranslatorException("Missing java info in java datamodel node");
}
@@ -141,23 +131,8 @@
*/
@Override
public void generateCodeEntry(String baseCodeGenDir) throws IOException {
-
- getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
- getJavaFileInfo().setPackage(getRootPackage(getVersion(), getNameSpace().getUri(),
- getRevision().getRevDate()));
- getJavaFileInfo().setPackageFilePath(
- getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
- getJavaFileInfo().setBaseCodeGenPath(baseCodeGenDir);
-
- String absloutePath = getAbsolutePackagePath(
- getJavaFileInfo().getBaseCodeGenPath(),
- getJavaFileInfo().getPackageFilePath());
-
- setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(
- getJavaFileInfo().getGeneratedFileTypes(), absloutePath,
- getJavaFileInfo().getJavaName()));
-
- getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
+ String modulePkg = getRootPackage(getVersion(), getNameSpace().getUri(), getRevision().getRevDate());
+ YangJavaModelUtils.generateCodeOfRootNode(this, baseCodeGenDir, modulePkg);
}
@Override
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaOutput.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaOutput.java
index 4228a4a..7718f71 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaOutput.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaOutput.java
@@ -17,31 +17,20 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
-
import org.onosproject.yangutils.datamodel.YangOutput;
import org.onosproject.yangutils.translator.exception.TranslatorException;
-import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
-import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
-import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
-import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
+import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
/**
* Represents output information extended to support java code generation.
*/
-public class YangJavaOutput extends YangOutput
- implements JavaCodeGenerator, HasJavaFileInfo,
- HasJavaImportData, HasTempJavaCodeFragmentFiles {
+public class YangJavaOutput extends YangOutput implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains information of the java file being generated.
@@ -77,7 +66,6 @@
*/
@Override
public JavaFileInfo getJavaFileInfo() {
-
if (javaFileInfo == null) {
throw new TranslatorException("Missing java info in java datamodel node");
}
@@ -144,28 +132,11 @@
*/
@Override
public void generateCodeEntry(String codeGenDir) throws IOException {
-
- getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
- getJavaFileInfo().setPackage(getCurNodePackage(this));
- getJavaFileInfo().setPackageFilePath(
- getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
- getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
-
- String absloutePath = getAbsolutePackagePath(
- getJavaFileInfo().getBaseCodeGenPath(),
- getJavaFileInfo().getPackageFilePath());
- createPackage(absloutePath, getName());
- setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(
- getJavaFileInfo().getGeneratedFileTypes(), absloutePath,
- getJavaFileInfo().getJavaName()));
-
- getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
-
- getTempJavaCodeFragmentFiles().addCurNodeInfoInParentTempFile(this, false);
+ generateCodeOfNode(this, codeGenDir, false);
}
/**
- * Create a java file using the YANG grouping info.
+ * Creates a java file using the YANG grouping info.
*
* @throws IOException IO operation fail
*/
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaSubModule.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaSubModule.java
index 34de136..177fad8 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaSubModule.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaSubModule.java
@@ -16,31 +16,22 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
-
import org.onosproject.yangutils.datamodel.YangBelongsTo;
import org.onosproject.yangutils.datamodel.YangSubModule;
import org.onosproject.yangutils.translator.exception.TranslatorException;
-import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
-import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
-import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
+import org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
/**
- * Represents Sub module information extended to support java code generation.
+ * Represents sub module information extended to support java code generation.
*/
-public class YangJavaSubModule extends YangSubModule
- implements JavaCodeGenerator, HasJavaFileInfo,
- HasJavaImportData, HasTempJavaCodeFragmentFiles {
+public class YangJavaSubModule extends YangSubModule implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains the information of the java file being generated.
@@ -76,7 +67,6 @@
*/
@Override
public JavaFileInfo getJavaFileInfo() {
-
if (javaFileInfo == null) {
throw new TranslatorException("Missing java info in java datamodel node");
}
@@ -150,33 +140,18 @@
* Prepare the information for java code generation corresponding to YANG
* container info.
*
- * @param codeGenDir code generation directory
+ * @param baseCodeGenDir code generation directory
* @throws IOException IO operation fail
*/
@Override
- public void generateCodeEntry(String codeGenDir) throws IOException {
-
- getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
- getJavaFileInfo().setPackage(getRootPackage(getVersion(),
- getNameSpaceFromModule(getBelongsTo()),
- getRevision().getRevDate()));
- getJavaFileInfo().setPackageFilePath(
- getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
- getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
-
- String absloutePath = getAbsolutePackagePath(
- getJavaFileInfo().getBaseCodeGenPath(),
- getJavaFileInfo().getPackageFilePath());
-
- setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(
- getJavaFileInfo().getGeneratedFileTypes(), absloutePath,
- getJavaFileInfo().getJavaName()));
-
- getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
+ public void generateCodeEntry(String baseCodeGenDir) throws IOException {
+ String subModulePkg = getRootPackage(getVersion(), getNameSpaceFromModule(getBelongsTo()),
+ getRevision().getRevDate());
+ YangJavaModelUtils.generateCodeOfRootNode(this, baseCodeGenDir, subModulePkg);
}
/**
- * Create a java file using the YANG grouping info.
+ * Creates a java file using the YANG grouping info.
*/
@Override
public void generateCodeExit() {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangJavaModelUtils.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangJavaModelUtils.java
new file mode 100644
index 0000000..6ba2f7d
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangJavaModelUtils.java
@@ -0,0 +1,162 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.translator.tojava.utils;
+
+import java.io.IOException;
+import org.onosproject.yangutils.datamodel.YangLeavesHolder;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
+import org.onosproject.yangutils.translator.tojava.javamodel.JavaCodeGeneratorInfo;
+
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
+
+/**
+ * Represents utility class for YANG java model.
+ */
+public final class YangJavaModelUtils {
+
+ /**
+ * Creates YANG java model utility.
+ */
+ private YangJavaModelUtils() {
+ }
+
+ /**
+ * Updates YANG java file package information.
+ *
+ * @param javaCodeGeneratorInfo YANG java file info node
+ * @param codeGenDir code generation directory
+ * @throws IOException IO operations fails
+ */
+ private static void updatePackageInfo(JavaCodeGeneratorInfo javaCodeGeneratorInfo, String codeGenDir)
+ throws IOException {
+ javaCodeGeneratorInfo.getJavaFileInfo()
+ .setJavaName(getCaptialCase(getCamelCase(((YangNode) javaCodeGeneratorInfo).getName())));
+ javaCodeGeneratorInfo.getJavaFileInfo().setPackage(getCurNodePackage((YangNode) javaCodeGeneratorInfo));
+ javaCodeGeneratorInfo.getJavaFileInfo().setPackageFilePath(
+ getPackageDirPathFromJavaJPackage(javaCodeGeneratorInfo.getJavaFileInfo().getPackage()));
+ javaCodeGeneratorInfo.getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
+ }
+
+ /**
+ * Updates YANG java file package information for specified package.
+ *
+ * @param javaCodeGeneratorInfo YANG java file info node
+ * @param codeGenDir code generation directory
+ * @throws IOException IO operations fails
+ */
+ private static void updatePackageInfo(JavaCodeGeneratorInfo javaCodeGeneratorInfo, String codeGenDir, String pkg)
+ throws IOException {
+ javaCodeGeneratorInfo.getJavaFileInfo()
+ .setJavaName(getCaptialCase(getCamelCase(((YangNode) javaCodeGeneratorInfo).getName())));
+ javaCodeGeneratorInfo.getJavaFileInfo().setPackage(pkg);
+ javaCodeGeneratorInfo.getJavaFileInfo().setPackageFilePath(
+ getPackageDirPathFromJavaJPackage(javaCodeGeneratorInfo.getJavaFileInfo().getPackage()));
+ javaCodeGeneratorInfo.getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
+ }
+
+ /**
+ * Updates temporary java code fragment files.
+ *
+ * @param javaCodeGeneratorInfo YANG java file info node
+ * @throws IOException IO operations fails
+ */
+ private static void createTempFragmentFile(JavaCodeGeneratorInfo javaCodeGeneratorInfo) throws IOException {
+ String absolutePath = getAbsolutePackagePath(javaCodeGeneratorInfo.getJavaFileInfo().getBaseCodeGenPath(),
+ javaCodeGeneratorInfo.getJavaFileInfo().getPackageFilePath());
+
+ javaCodeGeneratorInfo.setTempJavaCodeFragmentFiles(
+ new TempJavaCodeFragmentFiles(javaCodeGeneratorInfo.getJavaFileInfo().getGeneratedFileTypes(),
+ absolutePath, javaCodeGeneratorInfo.getJavaFileInfo().getJavaName()));
+ }
+
+ /**
+ * Updates leaf information in temporary java code fragment files.
+ *
+ * @param javaCodeGeneratorInfo YANG java file info node
+ * @throws IOException IO operations fails
+ */
+ private static void updateLeafInfoInTempFragmentFiles(JavaCodeGeneratorInfo javaCodeGeneratorInfo)
+ throws IOException {
+
+ if (javaCodeGeneratorInfo instanceof YangLeavesHolder) {
+ javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles()
+ .addCurNodeLeavesInfoToTempFiles((YangNode) javaCodeGeneratorInfo);
+ } else {
+ // TODO: either write a util for ENUM and UNION or, call the
+ // corresponding implementation in ENUM and UNION
+ }
+ }
+
+ /**
+ * Process generate code entry of YANG node.
+ *
+ * @param javaCodeGeneratorInfo YANG java file info node
+ * @param codeGenDir code generation directory
+ * @throws IOException IO operations fails
+ */
+ private static void generateTempFiles(JavaCodeGeneratorInfo javaCodeGeneratorInfo, String codeGenDir)
+ throws IOException {
+ if (!(javaCodeGeneratorInfo instanceof YangNode)) {
+ // TODO:throw exception
+ }
+ createTempFragmentFile(javaCodeGeneratorInfo);
+ updateLeafInfoInTempFragmentFiles(javaCodeGeneratorInfo);
+
+ }
+
+ /**
+ * Process generate code entry of YANG node.
+ *
+ * @param javaCodeGeneratorInfo YANG java file info node
+ * @param codeGenDir code generation directory
+ * @param isMultiInstance flag to indicate whether it's a list
+ * @throws IOException IO operations fails
+ */
+ public static void generateCodeOfNode(JavaCodeGeneratorInfo javaCodeGeneratorInfo, String codeGenDir,
+ boolean isMultiInstance) throws IOException {
+ if (!(javaCodeGeneratorInfo instanceof YangNode)) {
+ // TODO:throw exception
+ }
+ updatePackageInfo(javaCodeGeneratorInfo, codeGenDir);
+ generateTempFiles(javaCodeGeneratorInfo, codeGenDir);
+
+ javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles()
+ .addCurNodeInfoInParentTempFile((YangNode) javaCodeGeneratorInfo, isMultiInstance);
+ }
+
+ /**
+ * Process generate code entry of root node.
+ *
+ * @param javaCodeGeneratorInfo YANG java file info node
+ * @param codeGenDir code generation directory
+ * @param rootPkg package of the root node
+ * @throws IOException IO operations fails
+ */
+ public static void generateCodeOfRootNode(JavaCodeGeneratorInfo javaCodeGeneratorInfo, String codeGenDir,
+ String rootPkg) throws IOException {
+ if (!(javaCodeGeneratorInfo instanceof YangNode)) {
+ // TODO:throw exception
+ }
+ updatePackageInfo(javaCodeGeneratorInfo, codeGenDir, rootPkg);
+ generateTempFiles(javaCodeGeneratorInfo, codeGenDir);
+ }
+}
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/EnumListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/EnumListenerTest.java
index 79a9a45..67ef587 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/EnumListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/EnumListenerTest.java
@@ -64,8 +64,8 @@
assertThat(leafInfo.getLeafName(), is("speed"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("enumeration"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.ENUMERATION));
- assertThat(((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getEnumerationName(),
- is("speed"));
+ assertThat(((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getName(),
+ is("speed_enum"));
Set<YangEnum> enumSet = ((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getEnumSet();
for (YangEnum tmp : enumSet) {
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ValueListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ValueListenerTest.java
index 1864765..fb7c1d0 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ValueListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ValueListenerTest.java
@@ -64,8 +64,8 @@
assertThat(leafInfo.getLeafName(), is("speed"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("enumeration"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.ENUMERATION));
- assertThat(((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getEnumerationName(),
- is("speed"));
+ assertThat(((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getName(),
+ is("speed_enum"));
Set<YangEnum> enumSet = ((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getEnumSet();
for (YangEnum tmp : enumSet) {
@@ -103,8 +103,8 @@
assertThat(leafInfo.getLeafName(), is("speed"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("enumeration"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.ENUMERATION));
- assertThat(((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getEnumerationName(),
- is("speed"));
+ assertThat(((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getName(),
+ is("speed_enum"));
Set<YangEnum> enumSet = ((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getEnumSet();
for (YangEnum tmp : enumSet) {