YANG Translator optimization
Change-Id: Ie6a6b9d371a4fc5fd973cf56d6f3c7b44a3146ba
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
index 69b0376..13d5e66 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
@@ -15,20 +15,14 @@
*/
package org.onosproject.yangutils.datamodel;
-import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
-
-import java.io.IOException;
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.translator.CachedFileHandle;
-import org.onosproject.yangutils.translator.CodeGenerator;
-import org.onosproject.yangutils.translator.GeneratedFileType;
-import org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax;
import org.onosproject.yangutils.utils.YangConstructType;
-import org.onosproject.yangutils.utils.io.impl.FileSystemUtil;
+
+import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
/*-
* Reference:RFC 6020.
@@ -74,7 +68,7 @@
* Data model node to maintain information defined in YANG module.
*/
public class YangModule extends YangNode
- implements YangLeavesHolder, YangDesc, YangReference, Parsable, CodeGenerator, CollisionDetector {
+ implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector {
/**
* Name of the module.
@@ -157,11 +151,6 @@
*/
private byte version;
- /**
- * Cached Java File Handle.
- */
- private CachedFileHandle fileHandle;
-
/*-
* Reference RFC 6020.
*
@@ -510,52 +499,6 @@
}
/**
- * Get the mapped java package.
- *
- * @return the java package
- */
- @Override
- public String getPackage() {
- if (getFileHandle() != null) {
- return getFileHandle().getRelativeFilePath().replace("/", ".");
- }
- return null;
- }
-
- /**
- * Set the mapped java package.
- *
- * @param pcg the package to set
- */
- @Override
- public void setPackage(String pcg) {
- if (getFileHandle() != null) {
- pcg.replace(".", "/");
- getFileHandle().setRelativeFilePath(pcg);
- }
- }
-
- /**
- * Get the cached file handle.
- *
- * @return the fileHandle
- */
- @Override
- public CachedFileHandle getFileHandle() {
- return fileHandle;
- }
-
- /**
- * Set the cached file handle.
- *
- * @param handle the fileHandle to set
- */
- @Override
- public void setFileHandle(CachedFileHandle handle) {
- fileHandle = handle;
- }
-
- /**
* Get the list of nested reference's which required resolution.
*
* @return list of nested reference's which required resolution
@@ -623,64 +566,6 @@
}
/**
- * Generates java code for module.
- *
- * @param codeGenDir code generation directory
- * @throws IOException when fails to generate the source files
- */
- @Override
- public void generateJavaCodeEntry(String codeGenDir) throws IOException {
- String modPkg = JavaIdentifierSyntax.getRootPackage(getVersion(), getNameSpace().getUri(),
- getRevision().getRevDate());
-
- modPkg = JavaIdentifierSyntax.getCamelCase(modPkg);
- CachedFileHandle handle = null;
- try {
- FileSystemUtil.createPackage(codeGenDir + modPkg, getName());
- handle = FileSystemUtil.createSourceFiles(modPkg, getName(),
- GeneratedFileType.GENERATE_INTERFACE_WITH_BUILDER);
- handle.setCodeGenFilePath(codeGenDir);
- } catch (IOException e) {
- throw new IOException("Failed to create the source files.");
- }
-
- setFileHandle(handle);
- addLeavesAttributes();
- addLeafListAttributes();
- }
-
- @Override
- public void generateJavaCodeExit() throws IOException {
- getFileHandle().close();
- return;
- }
-
- /**
- * Adds leaf attributes in generated files.
- */
- private void addLeavesAttributes() {
-
- List<YangLeaf> leaves = getListOfLeaf();
- if (leaves != null) {
- for (YangLeaf leaf : leaves) {
- getFileHandle().addAttributeInfo(leaf.getDataType(), leaf.getLeafName(), false);
- }
- }
- }
-
- /**
- * Adds leaf list's attributes in generated files.
- */
- private void addLeafListAttributes() {
- List<YangLeafList> leavesList = getListOfLeafList();
- if (leavesList != null) {
- for (YangLeafList leafList : leavesList) {
- getFileHandle().addAttributeInfo(leafList.getDataType(), leafList.getLeafName(), true);
- }
- }
- }
-
- /**
* Add a type to resolve the nested references.
*
* @param node grouping or typedef node which needs to be resolved
@@ -715,4 +600,5 @@
public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
// Not required as module doesn't have any parent.
}
+
}