[ONOS-4711] Removed cyclic dependencies
Change-Id: I9ffea9a1a1b72f6ed3a23c0edb04cfc37bd8e48e
diff --git a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
index f7ac5f2..659773f 100644
--- a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
+++ b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
@@ -31,11 +31,11 @@
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+
/**
* Represents utilities for data model tree.
*/
public final class DataModelUtils {
-
/**
* Creates a new data model tree utility.
*/
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/YangLinker.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/YangLinker.java
index bbb673a..5f029f2 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/YangLinker.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/YangLinker.java
@@ -17,7 +17,7 @@
package org.onosproject.yangutils.linker;
import java.util.Set;
-import org.onosproject.yangutils.plugin.manager.YangFileInfo;
+import org.onosproject.yangutils.datamodel.YangNode;
/**
* Abstraction of entity which provides linking service of YANG files.
@@ -28,7 +28,7 @@
* Resolve the import and include dependencies for a given resolution
* information.
*
- * @param yangFileInfoSet set of all dependent YANG files
+ * @param yangNodeSet set of all dependent YANG nodes
*/
- void resolveDependencies(Set<YangFileInfo> yangFileInfoSet);
+ void resolveDependencies(Set<YangNode> yangNodeSet);
}
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerManager.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerManager.java
index 4e8a60a..96e1bcc 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerManager.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerManager.java
@@ -25,7 +25,6 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.linker.YangLinker;
import org.onosproject.yangutils.linker.exceptions.LinkerException;
-import org.onosproject.yangutils.plugin.manager.YangFileInfo;
import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
@@ -53,53 +52,51 @@
/**
* Creates YANG nodes set.
*
- * @param yangFileInfoSet YANG file information set
+ * @param yangNodeSet YANG node information set
*/
- public void createYangNodeSet(Set<YangFileInfo> yangFileInfoSet) {
- for (YangFileInfo yangFileInfo : yangFileInfoSet) {
- getYangNodeSet().add(yangFileInfo.getRootNode());
- }
+ public void createYangNodeSet(Set<YangNode> yangNodeSet) {
+ getYangNodeSet().addAll(yangNodeSet);
}
@Override
- public void resolveDependencies(Set<YangFileInfo> yangFileInfoSet) {
+ public void resolveDependencies(Set<YangNode> yangNodeSet) {
// Create YANG node set.
- createYangNodeSet(yangFileInfoSet);
+ createYangNodeSet(yangNodeSet);
// Carry out linking of sub module with module.
- linkSubModulesToParentModule(yangFileInfoSet);
+ linkSubModulesToParentModule(yangNodeSet);
// Add references to import list.
- addRefToYangFilesImportList(yangFileInfoSet);
+ addRefToYangFilesImportList(yangNodeSet);
// Add reference to include list.
- addRefToYangFilesIncludeList(yangFileInfoSet);
+ addRefToYangFilesIncludeList(yangNodeSet);
// TODO check for circular import/include.
// Carry out inter-file linking.
- processInterFileLinking(yangFileInfoSet);
+ processInterFileLinking(yangNodeSet);
}
/**
* Resolves sub-module linking by linking sub module with parent module.
*
- * @param yangFileInfoSet set of YANG files info
+ * @param yangNodeSet set of YANG files info
* @throws LinkerException fails to link sub-module to parent module
*/
- public void linkSubModulesToParentModule(Set<YangFileInfo> yangFileInfoSet)
+ public void linkSubModulesToParentModule(Set<YangNode> yangNodeSet)
throws LinkerException {
- for (YangFileInfo yangFileInfo : yangFileInfoSet) {
- YangNode yangNode = yangFileInfo.getRootNode();
+ for (YangNode yangNode : yangNodeSet) {
if (yangNode instanceof YangSubModule) {
try {
((YangSubModule) yangNode).linkWithModule(getYangNodeSet());
} catch (DataModelException e) {
- String errorInfo = "YANG file error: " + yangFileInfo.getYangFileName() + " at line: "
+ String errorInfo = "YANG file error: " + yangNode.getName() + " at line: "
+ e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE
+ e.getMessage();
throw new LinkerException(errorInfo);
+ // TODO add file path in exception message in util manager.
}
}
}
@@ -108,20 +105,20 @@
/**
* Adds imported node information to the import list.
*
- * @param yangFileInfoSet set of YANG files info
+ * @param yangNodeSet set of YANG files info
* @throws LinkerException fails to find imported module
*/
- public void addRefToYangFilesImportList(Set<YangFileInfo> yangFileInfoSet) throws LinkerException {
- for (YangFileInfo yangFileInfo : yangFileInfoSet) {
- YangNode yangNode = yangFileInfo.getRootNode();
+ public void addRefToYangFilesImportList(Set<YangNode> yangNodeSet) throws LinkerException {
+ for (YangNode yangNode : yangNodeSet) {
if (yangNode instanceof YangReferenceResolver) {
try {
((YangReferenceResolver) yangNode).addReferencesToImportList(getYangNodeSet());
} catch (DataModelException e) {
- String errorInfo = "Error in file: " + yangFileInfo.getYangFileName() + " at line: "
+ String errorInfo = "Error in file: " + yangNode.getName() + " at line: "
+ e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE
+ e.getMessage();
throw new LinkerException(errorInfo);
+ // TODO add file path in exception message in util manager.
}
}
}
@@ -130,20 +127,20 @@
/**
* Adds included node information to the include list.
*
- * @param yangFileInfoSet set of YANG files info
+ * @param yangNodeSet set of YANG files info
* @throws LinkerException fails to find included sub-module
*/
- public void addRefToYangFilesIncludeList(Set<YangFileInfo> yangFileInfoSet) throws LinkerException {
- for (YangFileInfo yangFileInfo : yangFileInfoSet) {
- YangNode yangNode = yangFileInfo.getRootNode();
+ public void addRefToYangFilesIncludeList(Set<YangNode> yangNodeSet) throws LinkerException {
+ for (YangNode yangNode : yangNodeSet) {
if (yangNode instanceof YangReferenceResolver) {
try {
((YangReferenceResolver) yangNode).addReferencesToIncludeList(getYangNodeSet());
} catch (DataModelException e) {
- String errorInfo = "Error in file: " + yangFileInfo.getYangFileName() + " at line: "
+ String errorInfo = "Error in file: " + yangNode.getName() + " at line: "
+ e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE
+ e.getMessage();
throw new LinkerException(errorInfo);
+ // TODO add file path in exception message in util manager.
}
}
}
@@ -152,20 +149,21 @@
/**
* Processes inter file linking for type and uses.
*
- * @param yangFileInfoSet set of YANG files info
+ * @param yangNodeSet set of YANG files info
* @throws LinkerException a violation in linker execution
*/
- public void processInterFileLinking(Set<YangFileInfo> yangFileInfoSet)
+ public void processInterFileLinking(Set<YangNode> yangNodeSet)
throws LinkerException {
- for (YangFileInfo yangFileInfo : yangFileInfoSet) {
+ for (YangNode yangNode : yangNodeSet) {
try {
- ((YangReferenceResolver) yangFileInfo.getRootNode()).resolveInterFileLinking(ResolvableType.YANG_USES);
- ((YangReferenceResolver) yangFileInfo.getRootNode())
+ ((YangReferenceResolver) yangNode).resolveInterFileLinking(ResolvableType.YANG_USES);
+ ((YangReferenceResolver) yangNode)
.resolveInterFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE);
} catch (DataModelException e) {
- String errorInfo = "Error in file: " + yangFileInfo.getYangFileName() + " at line: "
+ String errorInfo = "Error in file: " + yangNode.getName() + " at line: "
+ e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE + e.getMessage();
throw new LinkerException(errorInfo);
+ // TODO add file path in exception message in util manager.
}
}
}
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/YangUtilsParserManager.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/YangUtilsParserManager.java
index 6a5b1d2..9d78d13 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/YangUtilsParserManager.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/YangUtilsParserManager.java
@@ -17,7 +17,6 @@
package org.onosproject.yangutils.parser.impl;
import java.io.IOException;
-
import org.antlr.v4.runtime.ANTLRFileStream;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
@@ -101,4 +100,4 @@
// Returns the Root Node of the constructed data model tree.
return treeWalker.getRootNode();
}
-}
\ No newline at end of file
+}
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/AugmentListenerUtil.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/AugmentListenerUtil.java
index 1b2009e..341cbf9 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/AugmentListenerUtil.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/AugmentListenerUtil.java
@@ -31,7 +31,7 @@
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.datamodel.utils.YangConstructType.AUGMENT_DATA;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
/**
* Represents a utility which provides listener utilities augment node.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/plugin/manager/YangPluginUtils.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/plugin/manager/YangPluginUtils.java
new file mode 100644
index 0000000..ef218d5
--- /dev/null
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/plugin/manager/YangPluginUtils.java
@@ -0,0 +1,296 @@
+/*
+ * 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.plugin.manager;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Resource;
+import org.apache.maven.project.MavenProject;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.slf4j.Logger;
+import org.sonatype.plexus.build.incremental.BuildContext;
+
+import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN;
+import static org.onosproject.yangutils.utils.UtilConstants.JAR;
+import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
+import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
+import static org.onosproject.yangutils.utils.UtilConstants.TEMP;
+import static org.onosproject.yangutils.utils.UtilConstants.YANG_RESOURCES;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Represents YANG plugin utilities.
+ */
+public final class YangPluginUtils {
+
+ private static final Logger log = getLogger(YangPluginUtils.class);
+
+ private static final String TARGET_RESOURCE_PATH = SLASH + TEMP + SLASH + YANG_RESOURCES + SLASH;
+
+ private static final String SERIALIZED_FILE_EXTENSION = ".ser";
+
+ private YangPluginUtils() {
+ }
+
+ /**
+ * Adds generated source directory to the compilation root.
+ *
+ * @param source directory
+ * @param project current maven project
+ * @param context current build context
+ */
+ public static void addToCompilationRoot(String source, MavenProject project, BuildContext context) {
+ project.addCompileSourceRoot(source);
+ context.refresh(project.getBasedir());
+ log.info("Source directory added to compilation root: " + source);
+ }
+
+ /**
+ * Copies YANG files to the current project's output directory.
+ *
+ * @param yangFileInfo list of YANG files
+ * @param outputDir project's output directory
+ * @param project maven project
+ * @throws IOException when fails to copy files to destination resource directory
+ */
+ public static void copyYangFilesToTarget(Set<YangFileInfo> yangFileInfo, String outputDir, MavenProject project)
+ throws IOException {
+
+ List<File> files = getListOfFile(yangFileInfo);
+
+ String path = outputDir + TARGET_RESOURCE_PATH;
+ File targetDir = new File(path);
+ targetDir.mkdirs();
+
+ for (File file : files) {
+ Files.copy(file.toPath(),
+ new File(path + file.getName()).toPath(),
+ StandardCopyOption.REPLACE_EXISTING);
+ }
+ addToProjectResource(outputDir + SLASH + TEMP + SLASH, project);
+ }
+
+ /**
+ * Provides a list of files from list of strings.
+ *
+ * @param yangFileInfo set of yang file information
+ * @return list of files
+ */
+ private static List<File> getListOfFile(Set<YangFileInfo> yangFileInfo) {
+ List<File> files = new ArrayList<>();
+ Iterator<YangFileInfo> yangFileIterator = yangFileInfo.iterator();
+ while (yangFileIterator.hasNext()) {
+ YangFileInfo yangFile = yangFileIterator.next();
+ if (yangFile.isForTranslator()) {
+ files.add(new File(yangFile.getYangFileName()));
+ }
+ }
+ return files;
+ }
+
+ /**
+ * Serializes data-model.
+ *
+ * @param directory base directory for serialized files
+ * @param fileInfoSet YANG file info set
+ * @param project maven project
+ * @param operation true if need to add to resource
+ * @throws IOException when fails to do IO operations
+ */
+ public static void serializeDataModel(String directory, Set<YangFileInfo> fileInfoSet,
+ MavenProject project, boolean operation) throws IOException {
+
+ String serFileDirPath = directory + TARGET_RESOURCE_PATH;
+ File dir = new File(serFileDirPath);
+ dir.mkdirs();
+
+ if (operation) {
+ addToProjectResource(directory + SLASH + TEMP + SLASH, project);
+ }
+
+ for (YangFileInfo fileInfo : fileInfoSet) {
+
+ String serFileName = serFileDirPath + getCamelCase(fileInfo.getRootNode().getName(), null)
+ + SERIALIZED_FILE_EXTENSION;
+ fileInfo.setSerializedFile(serFileName);
+ FileOutputStream fileOutputStream = new FileOutputStream(serFileName);
+ ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
+ objectOutputStream.writeObject(fileInfo.getRootNode());
+ objectOutputStream.close();
+ fileOutputStream.close();
+ }
+ }
+
+ /**
+ * Returns de-serializes YANG data-model nodes.
+ *
+ * @param serailizedfileInfoSet YANG file info set
+ * @return de-serializes YANG data-model nodes
+ * @throws IOException when fails do IO operations
+ */
+ public static List<YangNode> deSerializeDataModel(List<String> serailizedfileInfoSet) throws IOException {
+
+ List<YangNode> nodes = new ArrayList<>();
+ for (String fileInfo : serailizedfileInfoSet) {
+ YangNode node = null;
+ try {
+ FileInputStream fileInputStream = new FileInputStream(fileInfo);
+ ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
+ node = (YangNode) objectInputStream.readObject();
+ nodes.add(node);
+ objectInputStream.close();
+ fileInputStream.close();
+ } catch (IOException | ClassNotFoundException e) {
+ throw new IOException(fileInfo + " not found.");
+ }
+ }
+ return nodes;
+ }
+
+ /**
+ * Returns list of jar path.
+ *
+ * @param project maven project
+ * @param localRepository local repository
+ * @param remoteRepos remote repository
+ * @return list of jar paths
+ */
+ private static List<String> resolveDependecyJarPath(MavenProject project, ArtifactRepository localRepository,
+ List<ArtifactRepository> remoteRepos) {
+
+ StringBuilder path = new StringBuilder();
+ List<String> jarPaths = new ArrayList<>();
+ for (Dependency dependency : project.getDependencies()) {
+
+ path.append(localRepository.getBasedir());
+ path.append(SLASH);
+ path.append(getPackageDirPathFromJavaJPackage(dependency.getGroupId()));
+ path.append(SLASH);
+ path.append(dependency.getArtifactId());
+ path.append(SLASH);
+ path.append(dependency.getVersion());
+ path.append(SLASH);
+ path.append(dependency.getArtifactId() + HYPHEN + dependency.getVersion() + PERIOD + JAR);
+ File jarFile = new File(path.toString());
+ if (jarFile.exists()) {
+ jarPaths.add(path.toString());
+ }
+ path.delete(0, path.length());
+ }
+
+ for (ArtifactRepository repo : remoteRepos) {
+ // TODO: add resolver for remote repo.
+ }
+ return jarPaths;
+ }
+
+ /**
+ * Resolves inter jar dependencies.
+ *
+ * @param project current maven project
+ * @param localRepository local maven repository
+ * @param remoteRepos list of remote repository
+ * @param directory directory for serialized files
+ * @return list of resolved datamodel nodes
+ * @throws IOException when fails to do IO operations
+ */
+ public static List<YangNode> resolveInterJarDependencies(MavenProject project, ArtifactRepository localRepository,
+ List<ArtifactRepository> remoteRepos, String directory)
+ throws IOException {
+
+ List<String> dependeciesJarPaths = resolveDependecyJarPath(project, localRepository, remoteRepos);
+ List<YangNode> resolvedDataModelNodes = new ArrayList<>();
+ for (String dependecy : dependeciesJarPaths) {
+ resolvedDataModelNodes.addAll(deSerializeDataModel(parseJarFile(dependecy, directory)));
+ }
+ return resolvedDataModelNodes;
+ }
+
+ /**
+ * Parses jar file and returns list of serialized file names.
+ *
+ * @param jarFile jar file to be parsed
+ * @param directory directory for keeping the searized files
+ * @return list of serialized files
+ * @throws IOException when fails to do IO operations
+ */
+ public static List<String> parseJarFile(String jarFile, String directory)
+ throws IOException {
+
+ List<String> serailizedFiles = new ArrayList<>();
+ JarFile jar = new JarFile(jarFile);
+ Enumeration<?> enumEntries = jar.entries();
+
+ File serializedFileDir = new File(directory);
+ serializedFileDir.mkdirs();
+ while (enumEntries.hasMoreElements()) {
+ JarEntry file = (JarEntry) enumEntries.nextElement();
+ if (file.getName().endsWith(SERIALIZED_FILE_EXTENSION)) {
+ if (file.getName().contains(SLASH)) {
+ String[] strArray = file.getName().split(SLASH);
+ String tempPath = "";
+ for (int i = 0; i < strArray.length - 1; i++) {
+ tempPath = SLASH + tempPath + SLASH + strArray[i];
+ }
+ File dir = new File(directory + tempPath);
+ dir.mkdirs();
+ }
+ File serailizedFile = new File(directory + SLASH + file.getName());
+ if (file.isDirectory()) {
+ serailizedFile.mkdirs();
+ continue;
+ }
+ InputStream inputStream = jar.getInputStream(file);
+
+ FileOutputStream fileOutputStream = new FileOutputStream(serailizedFile);
+ while (inputStream.available() > 0) {
+ fileOutputStream.write(inputStream.read());
+ }
+ fileOutputStream.close();
+ inputStream.close();
+ serailizedFiles.add(serailizedFile.toString());
+ }
+ }
+ jar.close();
+ return serailizedFiles;
+ }
+
+ /* Adds directory to resources of project */
+ private static void addToProjectResource(String dir, MavenProject project) {
+ Resource rsc = new Resource();
+ rsc.setDirectory(dir);
+ project.addResource(rsc);
+ }
+}
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/plugin/manager/YangUtilManager.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/plugin/manager/YangUtilManager.java
index 9339e4b..7240725 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/plugin/manager/YangUtilManager.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/plugin/manager/YangUtilManager.java
@@ -21,7 +21,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
@@ -37,25 +36,25 @@
import org.onosproject.yangutils.parser.YangUtilsParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
-import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil;
import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil;
import org.sonatype.plexus.build.incremental.BuildContext;
import static org.apache.maven.plugins.annotations.LifecyclePhase.GENERATE_SOURCES;
import static org.apache.maven.plugins.annotations.ResolutionScope.COMPILE;
+import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.addToCompilationRoot;
+import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.copyYangFilesToTarget;
+import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.resolveInterJarDependencies;
+import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.serializeDataModel;
import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode;
import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.translatorErrorHandler;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT_BASE_PKG;
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.YangIoUtils.addToCompilationRoot;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.copyYangFilesToTarget;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getDirectory;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.resolveInterJarDependencies;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.serializeDataModel;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage;
/**
* Represents ONOS YANG utility maven plugin.
@@ -64,7 +63,7 @@
* requiresDependencyResolution at compile time.
*/
@Mojo(name = "yang2java", defaultPhase = GENERATE_SOURCES, requiresDependencyResolution = COMPILE,
- requiresProject = true)
+ requiresProject = true)
public class YangUtilManager
extends AbstractMojo {
@@ -75,6 +74,8 @@
private YangLinker yangLinker = new YangLinkerManager();
private YangFileInfo curYangFileInfo = new YangFileInfo();
+ private Set<YangNode> yangNodeSet = new HashSet<>();
+
private static final String DEFAULT_PKG = SLASH + getPackageDirPathFromJavaJPackage(DEFAULT_BASE_PKG);
/**
@@ -217,6 +218,15 @@
}
/**
+ * Returns the YANG node set.
+ *
+ * @return YANG node set
+ */
+ public Set<YangNode> getYangNodeSet() {
+ return yangNodeSet;
+ }
+
+ /**
* Resolved inter-jar dependencies.
*
* @throws IOException when fails to do IO operations
@@ -244,10 +254,11 @@
*/
public void resolveDependenciesUsingLinker()
throws MojoExecutionException {
+ createYangNodeSet();
for (YangFileInfo yangFileInfo : getYangFileInfoSet()) {
setCurYangFileInfo(yangFileInfo);
try {
- yangLinker.resolveDependencies(getYangFileInfoSet());
+ yangLinker.resolveDependencies(getYangNodeSet());
} catch (LinkerException e) {
throw new MojoExecutionException(e.getMessage());
}
@@ -255,6 +266,15 @@
}
/**
+ * Creates YANG nodes set.
+ */
+ public void createYangNodeSet() {
+ for (YangFileInfo yangFileInfo : getYangFileInfoSet()) {
+ getYangNodeSet().add(yangFileInfo.getRootNode());
+ }
+ }
+
+ /**
* Parses all the provided YANG files and generates YANG data model tree.
*
* @throws IOException a violation in IO
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGenerator.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGenerator.java
index 277038c..1e0b14f 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGenerator.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGenerator.java
@@ -17,7 +17,7 @@
package org.onosproject.yangutils.translator.tojava;
import org.onosproject.yangutils.translator.exception.TranslatorException;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
/**
* Abstraction of an entity which provides Code generator functionalities.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/JavaCodeGeneratorInfo.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGeneratorInfo.java
similarity index 81%
rename from utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/JavaCodeGeneratorInfo.java
rename to utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGeneratorInfo.java
index 8dc0db5..6edd208 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/JavaCodeGeneratorInfo.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGeneratorInfo.java
@@ -14,10 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.translator.tojava.javamodel;
-
-import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
-import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer;
+package org.onosproject.yangutils.translator.tojava;
/**
* Represents YANG java info containing interface for java code generator, java
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGeneratorUtil.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGeneratorUtil.java
index a6eb9d7..fec42ca 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGeneratorUtil.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGeneratorUtil.java
@@ -20,7 +20,7 @@
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.translator.exception.TranslatorException;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.TraversalType.CHILD;
import static org.onosproject.yangutils.translator.tojava.TraversalType.PARENT;
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaFileInfo.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaFileInfo.java
index 28302ee..1c37e06 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaFileInfo.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaFileInfo.java
@@ -18,7 +18,7 @@
import java.io.Serializable;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
/**
* Represents cached java file handle, which supports the addition of member attributes and
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java
index 98e44f8..c7d4583 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java
@@ -22,13 +22,13 @@
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.javamodel.JavaLeafInfoContainer;
-import org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType;
-import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil;
+import org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType;
+import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil;
import com.google.common.base.MoreObjects;
-import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaImportClass;
-import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaImportPackage;
+import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.getJavaImportClass;
+import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.getJavaImportPackage;
/**
* Represents the information about individual imports in the generated file.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaBeanFragmentFiles.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaBeanFragmentFiles.java
index 14f4cd2..9ae2986 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaBeanFragmentFiles.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaBeanFragmentFiles.java
@@ -19,7 +19,7 @@
import java.io.File;
import java.io.IOException;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructor;
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaCodeFragmentFiles.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaCodeFragmentFiles.java
index 309ee66..beb8de0 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaCodeFragmentFiles.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaCodeFragmentFiles.java
@@ -21,7 +21,7 @@
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangTypeHolder;
import org.onosproject.yangutils.translator.exception.TranslatorException;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEnumerationFragmentFiles.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEnumerationFragmentFiles.java
index 2ab6f9d..238e01f 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEnumerationFragmentFiles.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEnumerationFragmentFiles.java
@@ -28,19 +28,19 @@
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaType;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
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.JavaFileGenerator.generateEnumClassFile;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPrefixForIdentifier;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPrefixForIdentifier;
import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.closeFile;
import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_FIRST_DIGIT;
import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUTO_PREFIX;
-import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
/**
* Represents implementation of java code fragments temporary implementations.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java
index 3c35a71..03ace2a 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java
@@ -33,7 +33,7 @@
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule;
import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
@@ -55,7 +55,7 @@
import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData;
import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedInfoOfFromString;
import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode;
-import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.updateJavaFileInfo;
+import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.updateJavaFileInfo;
import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaAttributeDefination;
import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderClassFile;
@@ -63,9 +63,9 @@
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateImplClassFile;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateInterfaceFile;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildString;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getDefaultConstructorString;
@@ -104,7 +104,7 @@
import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
import static org.onosproject.yangutils.utils.UtilConstants.SERVICE;
import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
-import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD;
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaServiceFragmentFiles.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaServiceFragmentFiles.java
index 0d6215e..e5a7308 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaServiceFragmentFiles.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaServiceFragmentFiles.java
@@ -25,7 +25,7 @@
import org.onosproject.yangutils.datamodel.YangNotification;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE;
@@ -46,10 +46,10 @@
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateManagerClassFile;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateServiceInterfaceFile;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcManagerMethod;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcServiceMethod;
@@ -67,7 +67,7 @@
import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME;
import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
import static org.onosproject.yangutils.utils.UtilConstants.VOID;
-import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateJavaDocForRpc;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE;
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaTypeFragmentFiles.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaTypeFragmentFiles.java
index 930b6b4..989ac0c 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaTypeFragmentFiles.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaTypeFragmentFiles.java
@@ -26,7 +26,7 @@
import org.onosproject.yangutils.datamodel.YangTypeHolder;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaType;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS;
@@ -36,13 +36,13 @@
import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateTypeDefClassFile;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateUnionClassFile;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOfMethodStringAndJavaDoc;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getTypeConstructorStringAndJavaDoc;
import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.closeFile;
import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
-import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
/**
* Represents implementation of java data type code fragments temporary implementations.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataType.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/AttributesJavaDataType.java
similarity index 83%
rename from utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataType.java
rename to utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/AttributesJavaDataType.java
index 19ed11d..a0840eb 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataType.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/AttributesJavaDataType.java
@@ -14,10 +14,9 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.translator.tojava.utils;
+package org.onosproject.yangutils.translator.tojava.javamodel;
import java.util.Stack;
-
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangDerivedInfo;
import org.onosproject.yangutils.datamodel.YangEnumeration;
@@ -26,48 +25,35 @@
import org.onosproject.yangutils.datamodel.YangTypeDef;
import org.onosproject.yangutils.datamodel.YangUnion;
import org.onosproject.yangutils.translator.exception.TranslatorException;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
-import org.onosproject.yangutils.translator.tojava.javamodel.JavaCodeGeneratorInfo;
-import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaEnumeration;
-import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule;
-import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule;
-import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDef;
-import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUnion;
+import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
-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.translator.tojava.javamodel.YangJavaModelUtils.getCurNodePackage;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER;
import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE;
import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_WRAPPER;
import static org.onosproject.yangutils.utils.UtilConstants.BYTE;
import static org.onosproject.yangutils.utils.UtilConstants.BYTE_WRAPPER;
-import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
-import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_METHOD_NAME;
import static org.onosproject.yangutils.utils.UtilConstants.INT;
import static org.onosproject.yangutils.utils.UtilConstants.INTEGER_WRAPPER;
import static org.onosproject.yangutils.utils.UtilConstants.JAVA_LANG;
import static org.onosproject.yangutils.utils.UtilConstants.JAVA_MATH;
import static org.onosproject.yangutils.utils.UtilConstants.LONG;
import static org.onosproject.yangutils.utils.UtilConstants.LONG_WRAPPER;
-import static org.onosproject.yangutils.utils.UtilConstants.NEW;
-import static org.onosproject.yangutils.utils.UtilConstants.PARSE_BOOLEAN;
-import static org.onosproject.yangutils.utils.UtilConstants.PARSE_BYTE;
-import static org.onosproject.yangutils.utils.UtilConstants.PARSE_INT;
-import static org.onosproject.yangutils.utils.UtilConstants.PARSE_LONG;
-import static org.onosproject.yangutils.utils.UtilConstants.PARSE_SHORT;
import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
import static org.onosproject.yangutils.utils.UtilConstants.SHORT;
import static org.onosproject.yangutils.utils.UtilConstants.SHORT_WRAPPER;
-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.YANG_BINARY_CLASS;
import static org.onosproject.yangutils.utils.UtilConstants.YANG_BITS_CLASS;
import static org.onosproject.yangutils.utils.UtilConstants.YANG_DECIMAL64_CLASS;
import static org.onosproject.yangutils.utils.UtilConstants.YANG_TYPES_PKG;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage;
/**
* Represents java data types info corresponding to YANG type.
@@ -121,51 +107,6 @@
}
/**
- * Returns from string method parsed string.
- *
- * @param targetDataType target data type
- * @param yangType YANG type
- * @return parsed string
- */
- public static String getParseFromStringMethod(String targetDataType, YangType<?> yangType) {
-
- YangDataTypes type = yangType.getDataType();
-
- switch (type) {
- case INT8:
- return BYTE_WRAPPER + PERIOD + PARSE_BYTE;
- case INT16:
- return SHORT_WRAPPER + PERIOD + PARSE_SHORT;
- case INT32:
- return INTEGER_WRAPPER + PERIOD + PARSE_INT;
- case INT64:
- return LONG_WRAPPER + PERIOD + PARSE_LONG;
- case UINT8:
- return SHORT_WRAPPER + PERIOD + PARSE_SHORT;
- case UINT16:
- return INTEGER_WRAPPER + PERIOD + PARSE_INT;
- case UINT32:
- return LONG_WRAPPER + PERIOD + PARSE_LONG;
- case UINT64:
- return NEW + SPACE + BIG_INTEGER;
- case STRING:
- return EMPTY_STRING;
- case EMPTY:
- case BOOLEAN:
- return BOOLEAN_WRAPPER + PERIOD + PARSE_BOOLEAN;
- case DECIMAL64:
- case BITS:
- case BINARY:
- case UNION:
- case ENUMERATION:
- case DERIVED:
- return targetDataType + PERIOD + FROM_STRING_METHOD_NAME;
- default:
- throw new TranslatorException("given data type is not supported.");
- }
- }
-
- /**
* Returns java import class.
*
* @param yangType YANG type
@@ -174,7 +115,7 @@
* @return java import class
*/
public static String getJavaImportClass(YangType<?> yangType, boolean isListAttr,
- YangToJavaNamingConflictUtil pluginConfig) {
+ YangToJavaNamingConflictUtil pluginConfig) {
YangDataTypes type = yangType.getDataType();
@@ -279,7 +220,7 @@
* @return java import package
*/
public static String getJavaImportPackage(YangType<?> yangType, boolean isListAttr,
- YangToJavaNamingConflictUtil conflictResolver) {
+ YangToJavaNamingConflictUtil conflictResolver) {
YangDataTypes type = yangType.getDataType();
@@ -425,7 +366,7 @@
* @return java package from parent node
*/
private static String getPackageFromParent(YangNode parent,
- YangToJavaNamingConflictUtil conflictResolver) {
+ YangToJavaNamingConflictUtil conflictResolver) {
if (!(parent instanceof JavaFileInfoContainer)) {
throw new TranslatorException("invalid child node is being processed.");
}
@@ -444,7 +385,7 @@
* @param conflictResolver yang plugin config
*/
public static void updateJavaFileInfo(YangNode yangNode,
- YangToJavaNamingConflictUtil conflictResolver) {
+ YangToJavaNamingConflictUtil conflictResolver) {
Stack<YangNode> nodesToUpdatePackage = new Stack<YangNode>();
/*
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/JavaLeafInfoContainer.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/JavaLeafInfoContainer.java
index 3722ad3..c57e3c4 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/JavaLeafInfoContainer.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/JavaLeafInfoContainer.java
@@ -17,7 +17,7 @@
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoContainer;
-import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil;
+import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil;
/**
* Represent java based identification of the YANG leaves.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/JavaQualifiedTypeResolver.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/JavaQualifiedTypeResolver.java
index 5b1e7c5..c85b1a2 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/JavaQualifiedTypeResolver.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/JavaQualifiedTypeResolver.java
@@ -16,7 +16,7 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoContainer;
-import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil;
+import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil;
/**
* Represent java based identification of the YANG leaves.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaAugment.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaAugment.java
index 6ac0fb7..cc54b24 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaAugment.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaAugment.java
@@ -20,12 +20,13 @@
import org.onosproject.yangutils.datamodel.YangAugment;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
-import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfAugmentableNode;
+import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfAugmentableNode;
/**
* Represents augment information extended to support java code generation.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaCase.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaCase.java
index ba7bd01..4652fd4 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaCase.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaCase.java
@@ -20,12 +20,13 @@
import org.onosproject.yangutils.datamodel.YangCase;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
-import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfAugmentableNode;
+import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfAugmentableNode;
/**
* Represents case information extended to support java code generation.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaChoice.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaChoice.java
index 4096972..1e29349 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaChoice.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaChoice.java
@@ -20,12 +20,13 @@
import org.onosproject.yangutils.datamodel.YangChoice;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK;
-import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeAndUpdateInParent;
+import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeAndUpdateInParent;
/**
* Represents choice information extended to support java code generation.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaContainer.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaContainer.java
index c056632..eac6291 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaContainer.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaContainer.java
@@ -20,12 +20,13 @@
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
-import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeAndUpdateInParent;
+import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeAndUpdateInParent;
/**
* Represents container information extended to support java code generation.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaEnumeration.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaEnumeration.java
index 16cabc2..2edd8d8 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaEnumeration.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaEnumeration.java
@@ -21,12 +21,13 @@
import org.onosproject.yangutils.datamodel.YangEnumeration;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS;
-import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
+import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfNode;
/**
* Represents YANG java enumeration information extended to support java code generation.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaGrouping.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaGrouping.java
index 8a90a44..808c4c1 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaGrouping.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaGrouping.java
@@ -20,11 +20,12 @@
import org.onosproject.yangutils.datamodel.YangGrouping;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
-import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.updatePackageInfo;
+import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.updatePackageInfo;
/**
* Represents grouping information extended to support java code generation.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaInput.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaInput.java
index db59174..7e6211a 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaInput.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaInput.java
@@ -21,12 +21,13 @@
import org.onosproject.yangutils.datamodel.YangInput;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
-import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfAugmentableNode;
+import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfAugmentableNode;
/**
* Represents input information extended to support java code generation.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaLeaf.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaLeaf.java
index 9f39dce..a9fa972 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaLeaf.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaLeaf.java
@@ -17,10 +17,10 @@
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
-import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil;
+import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil;
import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.updateLeavesJavaQualifiedInfo;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
/**
* Represents java information corresponding to the YANG leaf.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaLeafList.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaLeafList.java
index 91c550f..c22a134 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaLeafList.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaLeafList.java
@@ -17,10 +17,10 @@
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
-import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil;
+import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil;
import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.updateLeavesJavaQualifiedInfo;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
/**
* Represents java information corresponding to the YANG leaf-list.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaList.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaList.java
index 6f08b5d..e4a1997 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaList.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaList.java
@@ -20,12 +20,13 @@
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
-import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeAndUpdateInParent;
+import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeAndUpdateInParent;
/**
* Represents YANG list information extended to support java code generation.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangJavaModelUtils.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModelUtils.java
similarity index 89%
rename from utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangJavaModelUtils.java
rename to utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModelUtils.java
index 3f378c7..58eee77 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangJavaModelUtils.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModelUtils.java
@@ -14,24 +14,23 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.translator.tojava.utils;
+package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
-
import org.onosproject.yangutils.datamodel.RpcNotificationContainer;
import org.onosproject.yangutils.datamodel.YangCase;
import org.onosproject.yangutils.datamodel.YangChoice;
import org.onosproject.yangutils.datamodel.YangLeavesHolder;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangTypeHolder;
+import org.onosproject.yangutils.datamodel.utils.DataModelUtils;
import org.onosproject.yangutils.translator.exception.TranslatorException;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
-import org.onosproject.yangutils.translator.tojava.javamodel.JavaCodeGeneratorInfo;
-import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaEnumeration;
-import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule;
-import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.isRpcChildNodePresent;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS;
@@ -39,10 +38,10 @@
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.TempJavaFragmentFiles.addCurNodeInfoInParentTempFile;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
-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.UtilConstants.PERIOD;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage;
/**
* Represents utility class for YANG java model.
@@ -316,7 +315,7 @@
* @throws IOException IO operations fails
*/
public static void generateCodeOfRootNode(JavaCodeGeneratorInfo javaCodeGeneratorInfo,
- YangPluginConfig yangPluginConfig, String rootPkg)
+ YangPluginConfig yangPluginConfig, String rootPkg)
throws IOException {
if (!(javaCodeGeneratorInfo instanceof YangNode)) {
// TODO:throw exception
@@ -349,4 +348,26 @@
javaCodeGeneratorInfo.getJavaFileInfo().addGeneratedFileTypes(GENERATE_EVENT_LISTENER_INTERFACE);
}
+ /**
+ * Returns the node package string.
+ *
+ * @param curNode current java node whose package string needs to be set
+ * @return returns the root package string
+ */
+ public static String getCurNodePackage(YangNode curNode) {
+
+ String pkg;
+ if (!(curNode instanceof JavaFileInfoContainer)
+ || curNode.getParent() == null) {
+ throw new TranslatorException("missing parent node to get current node's package");
+ }
+
+ YangNode parentNode = DataModelUtils.getParentNodeInGenCode(curNode);
+ if (!(parentNode instanceof JavaFileInfoContainer)) {
+ throw new TranslatorException("missing parent java node to get current node's package");
+ }
+ JavaFileInfo parentJavaFileHandle = ((JavaFileInfoContainer) parentNode).getJavaFileInfo();
+ pkg = parentJavaFileHandle.getPackage() + PERIOD + parentJavaFileHandle.getJavaName();
+ return pkg.toLowerCase();
+ }
}
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java
index 1413f9c..b53ec92 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java
@@ -24,16 +24,17 @@
import org.onosproject.yangutils.datamodel.YangNotification;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
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.utils.JavaIdentifierSyntax.getRootPackage;
-import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfRootNode;
+import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfRootNode;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir;
/**
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaNotification.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaNotification.java
index 68f8164..61eebfb 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaNotification.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaNotification.java
@@ -22,17 +22,18 @@
import org.onosproject.yangutils.datamodel.YangNotification;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer;
import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
-import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfAugmentableNode;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
+import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfAugmentableNode;
import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING;
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaOutput.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaOutput.java
index dda3fc9..ce9ed6e 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaOutput.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaOutput.java
@@ -21,12 +21,13 @@
import org.onosproject.yangutils.datamodel.YangOutput;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
-import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfAugmentableNode;
+import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfAugmentableNode;
/**
* Represents output information extended to support java code generation.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaRpc.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaRpc.java
index f3730a2..fe72d18 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaRpc.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaRpc.java
@@ -26,19 +26,20 @@
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer;
import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode;
import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData;
import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
-import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.updatePackageInfo;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
+import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.updatePackageInfo;
import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE;
import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT;
import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE;
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaSubModule.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaSubModule.java
index d838682..31abd5c 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaSubModule.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaSubModule.java
@@ -26,16 +26,17 @@
import org.onosproject.yangutils.datamodel.YangSubModule;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
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.utils.JavaIdentifierSyntax.getRootPackage;
-import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfRootNode;
+import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfRootNode;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir;
/**
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaType.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaType.java
index e537743..1a96a3a 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaType.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaType.java
@@ -18,8 +18,7 @@
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
-import org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType;
-import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil;
+import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil;
/**
* Represents java information corresponding to the YANG type.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaTypeDef.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaTypeDef.java
index 0124510..3d33f3d 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaTypeDef.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaTypeDef.java
@@ -20,12 +20,13 @@
import org.onosproject.yangutils.datamodel.YangTypeDef;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
-import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
+import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfNode;
/**
* Represents type define information extended to support java code generation.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaUnion.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaUnion.java
index eac8e52..cca3e4b 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaUnion.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaUnion.java
@@ -20,12 +20,13 @@
import org.onosproject.yangutils.datamodel.YangUnion;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS;
-import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
+import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfNode;
/**
* Represents union information extended to support java code generation.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaUses.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaUses.java
index f6166a5..cef6202 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaUses.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaUses.java
@@ -25,13 +25,14 @@
import org.onosproject.yangutils.datamodel.YangUses;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode;
import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.addCurNodeAsAttributeInTargetTempFile;
-import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.updatePackageInfo;
+import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.updatePackageInfo;
/**
* Represents uses information extended to support java code generation.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java
index dde4b03..69f6d3e 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java
@@ -17,9 +17,9 @@
package org.onosproject.yangutils.translator.tojava.utils;
import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNotification;
import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer;
-import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaNotification;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
@@ -75,7 +75,7 @@
* / interface definition start.
*
* @param genFileTypes generated file type
- * @param yangName class name
+ * @param yangName class name
* @return class definition
*/
public static String generateClassDefinition(int genFileTypes, String yangName) {
@@ -85,19 +85,19 @@
* class / interface definition start.
*/
switch (genFileTypes) {
- case BUILDER_CLASS_MASK:
- return getBuilderClassDefinition(yangName);
- case IMPL_CLASS_MASK:
- return getImplClassDefinition(yangName);
- case BUILDER_INTERFACE_MASK:
- return getBuilderInterfaceDefinition(yangName);
- case GENERATE_TYPEDEF_CLASS:
- case GENERATE_UNION_CLASS:
- return getTypeClassDefinition(yangName);
- case GENERATE_ENUM_CLASS:
- return getEnumClassDefinition(yangName);
- default:
- return null;
+ case BUILDER_CLASS_MASK:
+ return getBuilderClassDefinition(yangName);
+ case IMPL_CLASS_MASK:
+ return getImplClassDefinition(yangName);
+ case BUILDER_INTERFACE_MASK:
+ return getBuilderInterfaceDefinition(yangName);
+ case GENERATE_TYPEDEF_CLASS:
+ case GENERATE_UNION_CLASS:
+ return getTypeClassDefinition(yangName);
+ case GENERATE_ENUM_CLASS:
+ return getEnumClassDefinition(yangName);
+ default:
+ return null;
}
}
@@ -106,8 +106,8 @@
* / interface definition start.
*
* @param genFileTypes generated file type
- * @param yangName class name
- * @param curNode current YANG node
+ * @param yangName class name
+ * @param curNode current YANG node
* @return class definition
*/
public static String generateClassDefinition(int genFileTypes, String yangName, YangNode curNode) {
@@ -117,19 +117,19 @@
* class / interface definition start.
*/
switch (genFileTypes) {
- case INTERFACE_MASK:
- return getInterfaceDefinition(yangName, curNode);
- case GENERATE_SERVICE_AND_MANAGER:
- return getRpcInterfaceDefinition(yangName, curNode);
- case GENERATE_EVENT_CLASS:
- String eventName = yangName + SUBJECT;
- return getEventDefinition(yangName, eventName);
- case GENERATE_EVENT_LISTENER_INTERFACE:
- return getEventListenerDefinition(yangName);
- case GENERATE_EVENT_SUBJECT_CLASS:
- return getClassDefinition(yangName);
- default:
- return null;
+ case INTERFACE_MASK:
+ return getInterfaceDefinition(yangName, curNode);
+ case GENERATE_SERVICE_AND_MANAGER:
+ return getRpcInterfaceDefinition(yangName, curNode);
+ case GENERATE_EVENT_CLASS:
+ String eventName = yangName + SUBJECT;
+ return getEventDefinition(yangName, eventName);
+ case GENERATE_EVENT_LISTENER_INTERFACE:
+ return getEventListenerDefinition(yangName);
+ case GENERATE_EVENT_SUBJECT_CLASS:
+ return getClassDefinition(yangName);
+ default:
+ return null;
}
}
@@ -174,7 +174,7 @@
* Returns builder interface file class definition.
*
* @param yangName java class name, corresponding to which the builder class
- * is being generated
+ * is being generated
* @return definition
*/
private static String getBuilderInterfaceDefinition(String yangName) {
@@ -227,7 +227,7 @@
* Returns RPC file interface definition.
*
* @param yangName file name
- * @param curNode current YANG node
+ * @param curNode current YANG node
* @return definition
*/
private static String getRpcInterfaceDefinition(String yangName, YangNode curNode) {
@@ -236,7 +236,7 @@
if (holder.getExtendsList() != null && !holder.getExtendsList().isEmpty()) {
curNode = curNode.getChild();
while (curNode != null) {
- if (curNode instanceof YangJavaNotification) {
+ if (curNode instanceof YangNotification) {
return getRpcInterfaceDefinitionWhenItExtends(yangName, holder);
}
curNode = curNode.getNextSibling();
@@ -251,7 +251,7 @@
/* Provides class definition when RPC interface needs to extends any event.*/
private static String getRpcInterfaceDefinitionWhenItExtends(String yangName,
- JavaExtendsListHolder holder) {
+ JavaExtendsListHolder holder) {
if (yangName.matches(REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE)) {
String[] strArray = yangName.split(SERVICE);
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java
index b254e87..3e523b0 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java
@@ -17,9 +17,10 @@
package org.onosproject.yangutils.translator.tojava.utils;
import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase;
import static org.onosproject.yangutils.utils.UtilConstants.ARRAY_LIST;
import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO;
import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET;
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaExtendsListHolder.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaExtendsListHolder.java
index 36986b8..efe3833 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaExtendsListHolder.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaExtendsListHolder.java
@@ -27,7 +27,7 @@
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.getTempJavaFragement;
/**
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
index c082d26..25b9c854 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
@@ -28,7 +28,8 @@
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer;
import org.onosproject.yangutils.translator.tojava.TempJavaEnumerationFragmentFiles;
import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles;
-import org.onosproject.yangutils.translator.tojava.javamodel.JavaCodeGeneratorInfo;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
@@ -65,7 +66,7 @@
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getDataFromTempFileHandle;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getEnumsValueAttribute;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.addActivateMethod;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.addDeActivateMethod;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddAugmentInfoMethodImpl;
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGeneratorUtils.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGeneratorUtils.java
index c940791..fc24ff9 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGeneratorUtils.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGeneratorUtils.java
@@ -31,6 +31,7 @@
import org.onosproject.yangutils.translator.tojava.TempJavaTypeFragmentFiles;
import org.onosproject.yangutils.utils.io.impl.CopyrightHeader;
import org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
@@ -64,8 +65,8 @@
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.utils.ClassDefinitionGenerator.generateClassDefinition;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getJavaPackageFromPackagePath;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getJavaPackageFromPackagePath;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase;
import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS;
import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT_ANNOTATION;
import static org.onosproject.yangutils.utils.UtilConstants.EQUAL;
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
index 95355aa..c9b2765 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
@@ -16,16 +16,18 @@
package org.onosproject.yangutils.translator.tojava.utils;
+import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
-
import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.datamodel.utils.DataModelUtils;
import org.onosproject.yangutils.translator.exception.TranslatorException;
-import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
+import org.onosproject.yangutils.utils.io.impl.YangIoUtils;
+import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil;
+import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode;
import static org.onosproject.yangutils.utils.UtilConstants.COLAN;
import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT_BASE_PKG;
import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
@@ -33,23 +35,17 @@
import static org.onosproject.yangutils.utils.UtilConstants.JAVA_KEY_WORDS;
import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
import static org.onosproject.yangutils.utils.UtilConstants.QUOTES;
-import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_DIGITS_WITH_SINGLE_LETTER;
import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_FIRST_DIGIT;
-import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_HYPHEN;
-import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_IDENTIFIER_SPECIAL_CHAR;
-import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_PERIOD;
-import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_SINGLE_LETTER;
-import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_UNDERSCORE;
import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_ALL_SPECIAL_CHAR;
-import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_DIGITS;
-import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_SINGLE_CAPITAL_CASE;
-import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_SINGLE_CAPITAL_CASE_AND_DIGITS_SMALL_CASES;
-import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_UPPERCASE;
import static org.onosproject.yangutils.utils.UtilConstants.REVISION_PREFIX;
import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
import static org.onosproject.yangutils.utils.UtilConstants.UNDER_SCORE;
import static org.onosproject.yangutils.utils.UtilConstants.VERSION_PREFIX;
-import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUTO_PREFIX;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.addPackageInfo;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.createDirectories;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getJavaPackageFromPackagePath;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage;
/**
* Represents an utility Class for translating the name from YANG to java convention.
@@ -73,14 +69,14 @@
/**
* Returns the root package string.
*
- * @param version YANG version
- * @param nameSpace name space of the module
- * @param revision revision of the module defined
+ * @param version YANG version
+ * @param nameSpace name space of the module
+ * @param revision revision of the module defined
* @param conflictResolver object of YANG to java naming conflict util
* @return the root package string
*/
public static String getRootPackage(byte version, String nameSpace, String revision,
- YangToJavaNamingConflictUtil conflictResolver) {
+ YangToJavaNamingConflictUtil conflictResolver) {
String pkg;
pkg = DEFAULT_BASE_PKG;
@@ -95,29 +91,6 @@
}
/**
- * Returns the node package string.
- *
- * @param curNode current java node whose package string needs to be set
- * @return returns the root package string
- */
- public static String getCurNodePackage(YangNode curNode) {
-
- String pkg;
- if (!(curNode instanceof JavaFileInfoContainer)
- || curNode.getParent() == null) {
- throw new TranslatorException("missing parent node to get current node's package");
- }
-
- YangNode parentNode = DataModelUtils.getParentNodeInGenCode(curNode);
- if (!(parentNode instanceof JavaFileInfoContainer)) {
- throw new TranslatorException("missing parent java node to get current node's package");
- }
- JavaFileInfo parentJavaFileHandle = ((JavaFileInfoContainer) parentNode).getJavaFileInfo();
- pkg = parentJavaFileHandle.getPackage() + PERIOD + parentJavaFileHandle.getJavaName();
- return pkg.toLowerCase();
- }
-
- /**
* Returns version.
*
* @param ver YANG version
@@ -130,7 +103,7 @@
/**
* Returns package name from name space.
*
- * @param nameSpace name space of YANG module
+ * @param nameSpace name space of YANG module
* @param conflictResolver object of YANG to java naming conflict util
* @return java package name as per java rules
*/
@@ -181,7 +154,7 @@
/**
* Returns the package string.
*
- * @param pkgArr package array
+ * @param pkgArr package array
* @param conflictResolver object of YANG to java naming conflict util
* @return package string
*/
@@ -193,7 +166,7 @@
for (String member : pkgArr) {
boolean presenceOfKeyword = JAVA_KEY_WORDS.contains(member.toLowerCase());
if (presenceOfKeyword || member.matches(REGEX_FOR_FIRST_DIGIT)) {
- String prefix = getPrefixForIdentifier(conflictResolver);
+ String prefix = YangIoUtils.getPrefixForIdentifier(conflictResolver);
member = prefix + member;
}
pkg = pkg + member;
@@ -206,252 +179,6 @@
}
/**
- * Prefix for adding with identifier and namespace, when it is a java keyword or starting with digits.
- *
- * @param conflictResolver object of YANG to java naming conflict util
- * @return prefix which needs to be added
- */
- public static String getPrefixForIdentifier(YangToJavaNamingConflictUtil conflictResolver) {
-
- String prefixForIdentifier = null;
- if (conflictResolver != null) {
- prefixForIdentifier = conflictResolver.getPrefixForIdentifier();
- }
- if (prefixForIdentifier != null) {
- prefixForIdentifier = prefixForIdentifier.replaceAll(REGEX_WITH_ALL_SPECIAL_CHAR, COLAN);
- String[] strArray = prefixForIdentifier.split(COLAN);
- try {
- if (strArray[0].isEmpty()) {
- List<String> stringArrangement = new ArrayList<String>();
- for (int i = 1; i < strArray.length; i++) {
- stringArrangement.add(strArray[i]);
- }
- strArray = stringArrangement.toArray(new String[stringArrangement.size()]);
- }
- prefixForIdentifier = strArray[0];
- for (int j = 1; j < strArray.length; j++) {
- prefixForIdentifier = prefixForIdentifier + strArray[j].substring(0, 1).toUpperCase() +
- strArray[j].substring(1);
- }
- } catch (ArrayIndexOutOfBoundsException outOfBoundsException) {
- throw new TranslatorException("The given prefix in pom.xml is invalid.");
- }
- } else {
- prefixForIdentifier = YANG_AUTO_PREFIX;
- }
- return prefixForIdentifier;
- }
-
- /**
- * Returns the YANG identifier name as java identifier.
- *
- * @param yangIdentifier identifier in YANG file
- * @param conflictResolver object of YANG to java naming conflict util
- * @return corresponding java identifier
- */
- public static String getCamelCase(String yangIdentifier, YangToJavaNamingConflictUtil conflictResolver) {
-
- if (conflictResolver != null) {
- String replacementForHyphen = conflictResolver.getReplacementForHyphen();
- String replacementForPeriod = conflictResolver.getReplacementForPeriod();
- String replacementForUnderscore = conflictResolver.getReplacementForUnderscore();
- if (replacementForPeriod != null) {
- yangIdentifier = yangIdentifier.replaceAll(REGEX_FOR_PERIOD,
- PERIOD + replacementForPeriod.toLowerCase() + PERIOD);
- }
- if (replacementForUnderscore != null) {
- yangIdentifier = yangIdentifier.replaceAll(REGEX_FOR_UNDERSCORE,
- UNDER_SCORE + replacementForUnderscore.toLowerCase() + UNDER_SCORE);
- }
- if (replacementForHyphen != null) {
- yangIdentifier = yangIdentifier.replaceAll(REGEX_FOR_HYPHEN,
- HYPHEN + replacementForHyphen.toLowerCase() + HYPHEN);
- }
- }
- yangIdentifier = yangIdentifier.replaceAll(REGEX_FOR_IDENTIFIER_SPECIAL_CHAR, COLAN);
- String[] strArray = yangIdentifier.split(COLAN);
- if (strArray[0].isEmpty()) {
- List<String> stringArrangement = new ArrayList<String>();
- for (int i = 1; i < strArray.length; i++) {
- stringArrangement.add(strArray[i]);
- }
- strArray = stringArrangement.toArray(new String[stringArrangement.size()]);
- }
- return upperCaseConflictResolver(strArray, conflictResolver);
- }
-
- /**
- * Resolves the conflict when input has upper case.
- *
- * @param stringArray containing strings for upper case conflict resolver
- * @param conflictResolver object of YANG to java naming conflict util
- * @return camel cased string
- */
- private static String upperCaseConflictResolver(String[] stringArray,
- YangToJavaNamingConflictUtil conflictResolver) {
-
- for (int l = 0; l < stringArray.length; l++) {
- String[] upperCaseSplitArray = stringArray[l].split(REGEX_WITH_UPPERCASE);
- for (int m = 0; m < upperCaseSplitArray.length; m++) {
- if (upperCaseSplitArray[m].matches(REGEX_WITH_SINGLE_CAPITAL_CASE)) {
- int check = m;
- while (check + 1 < upperCaseSplitArray.length) {
- if (upperCaseSplitArray[check + 1].matches(REGEX_WITH_SINGLE_CAPITAL_CASE)) {
- upperCaseSplitArray[check + 1] = upperCaseSplitArray[check + 1].toLowerCase();
- check = check + 1;
- } else if (upperCaseSplitArray[check + 1]
- .matches(REGEX_WITH_SINGLE_CAPITAL_CASE_AND_DIGITS_SMALL_CASES)) {
- upperCaseSplitArray[check + 1] = upperCaseSplitArray[check + 1].toLowerCase();
- break;
- } else {
- break;
- }
- }
- }
- }
- StringBuilder strBuilder = new StringBuilder();
- for (String element : upperCaseSplitArray) {
- strBuilder.append(element);
- }
- stringArray[l] = strBuilder.toString();
- }
- List<String> result = new ArrayList<String>();
- for (String element : stringArray) {
- String[] capitalCaseSplitArray = element.split(REGEX_WITH_UPPERCASE);
- for (String letter : capitalCaseSplitArray) {
- String[] arrayForAddition = letter.split(REGEX_WITH_DIGITS);
- List<String> list = Arrays.asList(arrayForAddition);
- for (String str : list) {
- if (str != null && !str.isEmpty()) {
- result.add(str);
- }
- }
- }
- }
- stringArray = result.toArray(new String[result.size()]);
- return applyCamelCaseRule(stringArray, conflictResolver);
- }
-
- /**
- * Applies the rule that a string does not end with a capitalized letter and capitalizes
- * the letter next to a number in an array.
- *
- * @param stringArray containing strings for camel case separation
- * @param conflictResolver object of YANG to java naming conflict util
- * @return camel case rule checked string
- */
- private static String applyCamelCaseRule(String[] stringArray, YangToJavaNamingConflictUtil conflictResolver) {
-
- String ruleChecker = stringArray[0].toLowerCase();
- int i;
- if (ruleChecker.matches(REGEX_FOR_FIRST_DIGIT)) {
- i = 0;
- ruleChecker = EMPTY_STRING;
- } else {
- i = 1;
- }
- for (; i < stringArray.length; i++) {
- if (i + 1 == stringArray.length) {
- if (stringArray[i].matches(REGEX_FOR_SINGLE_LETTER)
- || stringArray[i].matches(REGEX_FOR_DIGITS_WITH_SINGLE_LETTER)) {
- ruleChecker = ruleChecker + stringArray[i].toLowerCase();
- break;
- }
- }
- if (stringArray[i].matches(REGEX_FOR_FIRST_DIGIT)) {
- for (int j = 0; j < stringArray[i].length(); j++) {
- char letterCheck = stringArray[i].charAt(j);
- if (Character.isLetter(letterCheck)) {
- stringArray[i] = stringArray[i].substring(0, j)
- + stringArray[i].substring(j, j + 1).toUpperCase() + stringArray[i].substring(j + 1);
- break;
- }
- }
- ruleChecker = ruleChecker + stringArray[i];
- } else {
- ruleChecker = ruleChecker + stringArray[i].substring(0, 1).toUpperCase() + stringArray[i].substring(1);
- }
- }
- String ruleCheckerWithPrefix = addPrefix(ruleChecker, conflictResolver);
- return restrictConsecutiveCapitalCase(ruleCheckerWithPrefix);
- }
-
- /**
- * Adds prefix, if the string begins with digit or is a java key word.
- *
- * @param camelCasePrefix string for adding prefix
- * @param conflictResolver object of YANG to java naming conflict util
- * @return prefixed camel case string
- */
- private static String addPrefix(String camelCasePrefix, YangToJavaNamingConflictUtil conflictResolver) {
-
- String prefix = getPrefixForIdentifier(conflictResolver);
- if (camelCasePrefix.matches(REGEX_FOR_FIRST_DIGIT)) {
- camelCasePrefix = prefix + camelCasePrefix;
- }
- if (JAVA_KEY_WORDS.contains(camelCasePrefix)) {
- camelCasePrefix = prefix + camelCasePrefix.substring(0, 1).toUpperCase()
- + camelCasePrefix.substring(1);
- }
- return camelCasePrefix;
- }
-
- /**
- * Restricts consecutive capital cased string as a rule in camel case.
- *
- * @param consecCapitalCaseRemover which requires the restriction of consecutive capital case
- * @return string without consecutive capital case
- */
- private static String restrictConsecutiveCapitalCase(String consecCapitalCaseRemover) {
-
- for (int k = 0; k < consecCapitalCaseRemover.length(); k++) {
- if (k + 1 < consecCapitalCaseRemover.length()) {
- if (Character.isUpperCase(consecCapitalCaseRemover.charAt(k))) {
- if (Character.isUpperCase(consecCapitalCaseRemover.charAt(k + 1))) {
- consecCapitalCaseRemover = consecCapitalCaseRemover.substring(0, k + 1)
- + consecCapitalCaseRemover.substring(k + 1, k + 2).toLowerCase()
- + consecCapitalCaseRemover.substring(k + 2);
- }
- }
- }
- }
- return consecCapitalCaseRemover;
- }
-
- /**
- * Returns the YANG identifier name as java identifier with first letter
- * in capital.
- *
- * @param yangIdentifier identifier in YANG file
- * @return corresponding java identifier
- */
- public static String getCapitalCase(String yangIdentifier) {
- yangIdentifier = yangIdentifier.substring(0, 1).toUpperCase() + yangIdentifier.substring(1);
- return restrictConsecutiveCapitalCase(yangIdentifier);
- }
-
- /**
- * Returns the YANG identifier name as java identifier with first letter
- * in small.
- *
- * @param yangIdentifier identifier in YANG file.
- * @return corresponding java identifier
- */
- public static String getSmallCase(String yangIdentifier) {
- return yangIdentifier.substring(0, 1).toLowerCase() + yangIdentifier.substring(1);
- }
-
- /**
- * Returns the java Package from package path.
- *
- * @param packagePath package path
- * @return java package
- */
- public static String getJavaPackageFromPackagePath(String packagePath) {
- return packagePath.replace(SLASH, PERIOD);
- }
-
- /**
* Returns enum's java name.
*
* @param name enum's name
@@ -479,12 +206,46 @@
}
/**
- * Returns the directory path corresponding to java package.
+ * Creates a package structure with package info java file if not present.
*
- * @param packagePath package path
- * @return java package
+ * @param yangNode YANG node for which code is being generated
+ * @throws IOException any IO exception
*/
- public static String getPackageDirPathFromJavaJPackage(String packagePath) {
- return packagePath.replace(PERIOD, SLASH);
+ public static void createPackage(YangNode yangNode) throws IOException {
+ if (!(yangNode instanceof JavaFileInfoContainer)) {
+ throw new TranslatorException("current node must have java file info");
+ }
+ String pkgInfo;
+ JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) yangNode).getJavaFileInfo();
+ String pkg = getAbsolutePackagePath(javaFileInfo.getBaseCodeGenPath(), javaFileInfo.getPackageFilePath());
+ if (!doesPackageExist(pkg)) {
+ try {
+ File pack = createDirectories(pkg);
+ YangNode parent = getParentNodeInGenCode(yangNode);
+ if (parent != null) {
+ pkgInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo().getJavaName();
+ addPackageInfo(pack, pkgInfo, getJavaPackageFromPackagePath(pkg), true,
+ ((JavaFileInfoContainer) parent).getJavaFileInfo().getPluginConfig());
+ } else {
+ pkgInfo = ((JavaFileInfoContainer) yangNode).getJavaFileInfo().getJavaName();
+ addPackageInfo(pack, pkgInfo, getJavaPackageFromPackagePath(pkg), false,
+ ((JavaFileInfoContainer) yangNode).getJavaFileInfo().getPluginConfig());
+ }
+ } catch (IOException e) {
+ throw new IOException("failed to create package-info file");
+ }
+ }
+ }
+
+ /**
+ * Checks if the package directory structure created.
+ *
+ * @param pkg Package to check if it is created
+ * @return existence status of package
+ */
+ public static boolean doesPackageExist(String pkg) {
+ File pkgDir = new File(getPackageDirPathFromJavaJPackage(pkg));
+ File pkgWithFile = new File(pkgDir + SLASH + "package-info.java");
+ return pkgDir.exists() && pkgWithFile.isFile();
}
}
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
index b6889c8..92caa48 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
@@ -18,31 +18,28 @@
import java.util.List;
import java.util.Map;
-
-import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.datamodel.YangNodeIdentifier;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo;
-import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugment;
import org.onosproject.yangutils.utils.io.impl.JavaDocGen;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
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.AttributesJavaDataType.getParseFromStringMethod;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase;
import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE;
import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION;
import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.AND;
-import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTABLE;
import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTATION;
import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO;
+import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER;
import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE;
+import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_WRAPPER;
import static org.onosproject.yangutils.utils.UtilConstants.BUILD;
import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
import static org.onosproject.yangutils.utils.UtilConstants.BYTE;
+import static org.onosproject.yangutils.utils.UtilConstants.BYTE_WRAPPER;
import static org.onosproject.yangutils.utils.UtilConstants.CASE;
import static org.onosproject.yangutils.utils.UtilConstants.CATCH;
import static org.onosproject.yangutils.utils.UtilConstants.CHECK_NOT_NULL_STRING;
@@ -74,8 +71,10 @@
import static org.onosproject.yangutils.utils.UtilConstants.IMPL;
import static org.onosproject.yangutils.utils.UtilConstants.INSTANCE_OF;
import static org.onosproject.yangutils.utils.UtilConstants.INT;
+import static org.onosproject.yangutils.utils.UtilConstants.INTEGER_WRAPPER;
import static org.onosproject.yangutils.utils.UtilConstants.LIST;
import static org.onosproject.yangutils.utils.UtilConstants.LONG;
+import static org.onosproject.yangutils.utils.UtilConstants.LONG_WRAPPER;
import static org.onosproject.yangutils.utils.UtilConstants.NEW;
import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
import static org.onosproject.yangutils.utils.UtilConstants.NULL;
@@ -88,6 +87,11 @@
import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS;
import static org.onosproject.yangutils.utils.UtilConstants.OTHER;
import static org.onosproject.yangutils.utils.UtilConstants.OVERRIDE;
+import static org.onosproject.yangutils.utils.UtilConstants.PARSE_BOOLEAN;
+import static org.onosproject.yangutils.utils.UtilConstants.PARSE_BYTE;
+import static org.onosproject.yangutils.utils.UtilConstants.PARSE_INT;
+import static org.onosproject.yangutils.utils.UtilConstants.PARSE_LONG;
+import static org.onosproject.yangutils.utils.UtilConstants.PARSE_SHORT;
import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
import static org.onosproject.yangutils.utils.UtilConstants.QUOTES;
@@ -96,6 +100,7 @@
import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
import static org.onosproject.yangutils.utils.UtilConstants.SET_METHOD_PREFIX;
import static org.onosproject.yangutils.utils.UtilConstants.SHORT;
+import static org.onosproject.yangutils.utils.UtilConstants.SHORT_WRAPPER;
import static org.onosproject.yangutils.utils.UtilConstants.SIXTEEN_SPACE_INDENTATION;
import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
import static org.onosproject.yangutils.utils.UtilConstants.STARTED_LOG_INFO;
@@ -113,7 +118,6 @@
import static org.onosproject.yangutils.utils.UtilConstants.VALUE;
import static org.onosproject.yangutils.utils.UtilConstants.VOID;
import static org.onosproject.yangutils.utils.UtilConstants.YANG_UTILS_TODO;
-import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILD_METHOD;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.CONSTRUCTOR;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.DEFAULT_CONSTRUCTOR;
@@ -123,6 +127,10 @@
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.OF_METHOD;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SETTER_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.getCamelCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast;
/**
@@ -139,7 +147,7 @@
/**
* Returns the methods strings for builder interface.
*
- * @param name attribute name
+ * @param name attribute name
* @param pluginConfig plugin configurations
* @return method string for builder interface
*/
@@ -150,13 +158,13 @@
/**
* Returns getter string.
*
- * @param attr attribute info
+ * @param attr attribute info
* @param generatedJavaFiles generated java files
- * @param pluginConfig plugin configurations
+ * @param pluginConfig plugin configurations
* @return getter string
*/
public static String getGetterString(JavaAttributeInfo attr, int generatedJavaFiles,
- YangPluginConfig pluginConfig) {
+ YangPluginConfig pluginConfig) {
String returnType = getReturnType(attr);
String attributeName = attr.getAttributeName();
@@ -168,14 +176,14 @@
/**
* Returns setter string.
*
- * @param attr attribute info
- * @param className java class name
+ * @param attr attribute info
+ * @param className java class name
* @param generatedJavaFiles generated java files
- * @param pluginConfig plugin configurations
+ * @param pluginConfig plugin configurations
* @return setter string
*/
public static String getSetterString(JavaAttributeInfo attr, String className, int generatedJavaFiles,
- YangPluginConfig pluginConfig) {
+ YangPluginConfig pluginConfig) {
String attrType = getReturnType(attr);
String attributeName = attr.getAttributeName();
@@ -193,7 +201,7 @@
/**
* Returns constructor method string.
*
- * @param name class name
+ * @param name class name
* @param pluginConfig plugin configurations
* @return constructor string
*/
@@ -204,13 +212,13 @@
/**
* Returns default constructor method string.
*
- * @param name class name
+ * @param name class name
* @param modifierType modifier type
* @param pluginConfig plugin configurations
* @return default constructor string
*/
public static String getDefaultConstructorString(String name, String modifierType,
- YangPluginConfig pluginConfig) {
+ YangPluginConfig pluginConfig) {
return getJavaDoc(DEFAULT_CONSTRUCTOR, name, false, pluginConfig)
+ getDefaultConstructor(name, modifierType)
+ NEW_LINE;
@@ -240,7 +248,7 @@
/**
* Returns the getter method strings for class file.
*
- * @param attr attribute info
+ * @param attr attribute info
* @param generatedJavaFiles for the type of java file being generated
* @return getter method for class
*/
@@ -259,8 +267,8 @@
/**
* Returns getter for attribute.
*
- * @param type return type
- * @param name attribute name
+ * @param type return type
+ * @param name attribute name
* @param generatedJavaFiles generated java files
* @return getter for attribute
*/
@@ -283,23 +291,23 @@
/*Provides string to return for type.*/
private static String parseTypeForReturnValue(String type) {
switch (type) {
- case BYTE:
- case INT:
- case SHORT:
- case LONG:
- return "0";
- case BOOLEAN_DATA_TYPE:
- return FALSE;
- default:
- return null;
+ case BYTE:
+ case INT:
+ case SHORT:
+ case LONG:
+ return "0";
+ case BOOLEAN_DATA_TYPE:
+ return FALSE;
+ default:
+ return null;
}
}
/**
* Returns the setter method strings for class file.
*
- * @param attr attribute info
- * @param className name of the class
+ * @param attr attribute info
+ * @param className name of the class
* @param generatedJavaFiles generated java files
* @return setter method for class
*/
@@ -318,8 +326,8 @@
* Returns setter for attribute.
*
* @param className class name
- * @param name attribute name
- * @param type return type
+ * @param name attribute name
+ * @param type return type
* @return setter for attribute
*/
private static String getSetter(String className, String name, String type, int generatedJavaFiles) {
@@ -381,14 +389,14 @@
/**
* Returns the getter method strings for interface file.
*
- * @param yangName name of the attribute
- * @param returnType return type of attribute
- * @param isList is list attribute
+ * @param yangName name of the attribute
+ * @param returnType return type of attribute
+ * @param isList is list attribute
* @param generatedJavaFiles generated java files
* @return getter method for interface
*/
public static String getGetterForInterface(String yangName, String returnType, boolean isList,
- int generatedJavaFiles) {
+ int generatedJavaFiles) {
if (!isList) {
return getGetterInterfaceString(returnType, yangName, generatedJavaFiles);
@@ -401,11 +409,11 @@
* Returns getter for attribute in interface.
*
* @param returnType return type
- * @param yangName attribute name
+ * @param yangName attribute name
* @return getter for interface
*/
private static String getGetterInterfaceString(String returnType, String yangName,
- int generatedJavaFiles) {
+ int generatedJavaFiles) {
if ((generatedJavaFiles & GENERATE_SERVICE_AND_MANAGER) != 0) {
return FOUR_SPACE_INDENTATION + returnType + SPACE + GET_METHOD_PREFIX + getCapitalCase(yangName)
+ OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN;
@@ -418,15 +426,15 @@
/**
* Returns the setter method strings for interface file.
*
- * @param attrName name of the attribute
- * @param attrType return type of attribute
- * @param className name of the java class being generated
- * @param isList is list attribute
+ * @param attrName name of the attribute
+ * @param attrType return type of attribute
+ * @param className name of the java class being generated
+ * @param isList is list attribute
* @param generatedJavaFiles generated java files
* @return setter method for interface
*/
public static String getSetterForInterface(String attrName, String attrType, String className,
- boolean isList, int generatedJavaFiles) {
+ boolean isList, int generatedJavaFiles) {
if (!isList) {
return getSetterInterfaceString(className, attrName, attrType, generatedJavaFiles);
@@ -439,12 +447,12 @@
* Returns setter string for interface.
*
* @param className class name
- * @param attrName attribute name
- * @param attrType attribute type
+ * @param attrName attribute name
+ * @param attrType attribute type
* @return setter string
*/
private static String getSetterInterfaceString(String className, String attrName, String attrType,
- int generatedJavaFiles) {
+ int generatedJavaFiles) {
if ((generatedJavaFiles & GENERATE_SERVICE_AND_MANAGER) != 0) {
return FOUR_SPACE_INDENTATION + VOID + SPACE + SET_METHOD_PREFIX + getCapitalCase(attrName)
@@ -494,7 +502,7 @@
/**
* Returns constructor string for impl class.
*
- * @param yangName class name
+ * @param yangName class name
* @param pluginConfig plugin configurations
* @return constructor string
*/
@@ -512,14 +520,14 @@
/**
* Returns the constructor strings for class file.
*
- * @param yangName name of the class
- * @param attr attribute info
+ * @param yangName name of the class
+ * @param attr attribute info
* @param generatedJavaFiles generated java files
- * @param pluginConfig plugin configurations
+ * @param pluginConfig plugin configurations
* @return constructor for class
*/
public static String getConstructor(String yangName, JavaAttributeInfo attr, int generatedJavaFiles,
- YangPluginConfig pluginConfig) {
+ YangPluginConfig pluginConfig) {
String attributeName = attr.getAttributeName();
String constructor;
@@ -545,14 +553,14 @@
/**
* Returns the rpc strings for service interface.
*
- * @param rpcName name of the rpc
- * @param inputName name of input
- * @param outputName name of output
+ * @param rpcName name of the rpc
+ * @param inputName name of input
+ * @param outputName name of output
* @param pluginConfig plugin configurations
* @return rpc method string
*/
public static String getRpcServiceMethod(String rpcName, String inputName, String outputName,
- YangPluginConfig pluginConfig) {
+ YangPluginConfig pluginConfig) {
rpcName = getCamelCase(rpcName, pluginConfig.getConflictResolver());
if (!inputName.equals(EMPTY_STRING)) {
@@ -565,14 +573,14 @@
/**
* Returns the rpc strings for manager impl.
*
- * @param rpcName name of the rpc
- * @param inputName name of input
- * @param outputName name of output
+ * @param rpcName name of the rpc
+ * @param inputName name of input
+ * @param outputName name of output
* @param pluginConfig plugin configurations
* @return rpc method string
*/
public static String getRpcManagerMethod(String rpcName, String inputName, String outputName,
- YangPluginConfig pluginConfig) {
+ YangPluginConfig pluginConfig) {
rpcName = getCamelCase(rpcName, pluginConfig.getConflictResolver());
if (!inputName.equals(EMPTY_STRING)) {
@@ -608,7 +616,7 @@
/**
* Returns the Default constructor strings for class file.
*
- * @param name name of the class
+ * @param name name of the class
* @param modifierType modifier type for default constructor
* @return Default constructor for class
*/
@@ -663,7 +671,7 @@
/**
* Returns from string method's open string.
*
- * @param className name of the class
+ * @param className name of the class
* @param pluginConfig plugin configurations
* @return from string method's open string
*/
@@ -687,13 +695,13 @@
/**
* Return from string method's body string.
*
- * @param attr attribute info
+ * @param attr attribute info
* @param fromStringAttributeInfo attribute info for the from string
- * wrapper type
+ * wrapper type
* @return from string method's body string
*/
public static String getFromStringMethod(JavaAttributeInfo attr,
- JavaAttributeInfo fromStringAttributeInfo) {
+ JavaAttributeInfo fromStringAttributeInfo) {
return EIGHT_SPACE_INDENTATION + getTrySubString() + NEW_LINE + TWELVE_SPACE_INDENTATION
+ getParsedSubString(attr, fromStringAttributeInfo) + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION
@@ -736,7 +744,7 @@
* @return sub string with parsed statement for union's from string method
*/
private static String getParsedSubString(JavaAttributeInfo attr,
- JavaAttributeInfo fromStringAttributeInfo) {
+ JavaAttributeInfo fromStringAttributeInfo) {
String targetDataType = getReturnType(attr);
String parseFromStringMethod = getParseFromStringMethod(targetDataType,
@@ -865,13 +873,13 @@
/**
* Returns of method's string and java doc for special type.
*
- * @param attr attribute info
+ * @param attr attribute info
* @param generatedJavaClassName class name
- * @param pluginConfig plugin configurations
+ * @param pluginConfig plugin configurations
* @return of method's string and java doc for special type
*/
public static String getOfMethodStringAndJavaDoc(JavaAttributeInfo attr, String generatedJavaClassName,
- YangPluginConfig pluginConfig) {
+ YangPluginConfig pluginConfig) {
String attrType = getReturnType(attr);
String attrName = attr.getAttributeName();
@@ -883,7 +891,7 @@
/**
* Returns of method's string.
*
- * @param type data type
+ * @param type data type
* @param className class name
* @return of method's string
*/
@@ -898,13 +906,14 @@
/**
* Returns string and java doc for constructor of type class.
*
- * @param attr attribute info
+ * @param attr attribute info
* @param generatedJavaClassName class name
- * @param pluginConfig plugin configurations
+ * @param pluginConfig plugin configurations
* @return string and java doc for constructor of type class
*/
public static String getTypeConstructorStringAndJavaDoc(JavaAttributeInfo attr,
- String generatedJavaClassName, YangPluginConfig pluginConfig) {
+ String generatedJavaClassName,
+ YangPluginConfig pluginConfig) {
String attrType = getReturnType(attr);
String attrName = attr.getAttributeName();
@@ -916,8 +925,8 @@
/**
* Returns type constructor string.
*
- * @param type data type
- * @param name attribute name
+ * @param type data type
+ * @param name attribute name
* @param className class name
* @return type constructor string
*/
@@ -989,47 +998,18 @@
}
/**
- * Provides string to be added in augment node's constructor.
- *
- * @param curNode current YANG node
- * @return constructors string
- */
- public static String getAugmentsAddToAugmentedMethod(YangNode curNode) {
-
- if (!(curNode instanceof YangJavaAugment)) {
- throw new TranslatorException("current node should be of type augment node.");
- }
- YangJavaAugment augment = (YangJavaAugment) curNode;
- List<YangNodeIdentifier> targetNodes = augment.getTargetNode();
-
- String name = targetNodes.get(targetNodes.size() - 1).getName();
- String captialCase = getCapitalCase(name);
- String smallCase = getSmallCase(captialCase);
- return EIGHT_SPACE_INDENTATION + captialCase + IMPL + SPACE + smallCase + IMPL + SPACE + EQUAL + SPACE
- + NEW + SPACE + captialCase + BUILDER + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + NEW + SPACE
- + captialCase + IMPL + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE
- + EIGHT_SPACE_INDENTATION + smallCase + IMPL + PERIOD + ADD_STRING + AUGMENTATION
- + OPEN_PARENTHESIS + THIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
-
- }
-
- private static String getAugmentsAddToAugmentedMethodStart() {
- return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + ADD_STRING + AUGMENTABLE + OPEN_PARENTHESIS
- + CLOSE_PARENTHESIS + SPACE + OPEN_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 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
*/
public static String getEnumsOfMethod(String className, JavaAttributeInfo attr,
- Map<String, Integer> enumMap, List<String> enumList, YangPluginConfig pluginConfig) {
+ Map<String, Integer> enumMap, List<String> enumList,
+ YangPluginConfig pluginConfig) {
String attrType = getReturnType(attr);
String attrName = attr.getAttributeName();
@@ -1083,4 +1063,48 @@
+ STOPPED_LOG_INFO + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
}
+ /**
+ * Returns from string method parsed string.
+ *
+ * @param targetDataType target data type
+ * @param yangType YANG type
+ * @return parsed string
+ */
+ public static String getParseFromStringMethod(String targetDataType, YangType<?> yangType) {
+
+ YangDataTypes type = yangType.getDataType();
+
+ switch (type) {
+ case INT8:
+ return BYTE_WRAPPER + PERIOD + PARSE_BYTE;
+ case INT16:
+ return SHORT_WRAPPER + PERIOD + PARSE_SHORT;
+ case INT32:
+ return INTEGER_WRAPPER + PERIOD + PARSE_INT;
+ case INT64:
+ return LONG_WRAPPER + PERIOD + PARSE_LONG;
+ case UINT8:
+ return SHORT_WRAPPER + PERIOD + PARSE_SHORT;
+ case UINT16:
+ return INTEGER_WRAPPER + PERIOD + PARSE_INT;
+ case UINT32:
+ return LONG_WRAPPER + PERIOD + PARSE_LONG;
+ case UINT64:
+ return NEW + SPACE + BIG_INTEGER;
+ case STRING:
+ return EMPTY_STRING;
+ case EMPTY:
+ case BOOLEAN:
+ return BOOLEAN_WRAPPER + PERIOD + PARSE_BOOLEAN;
+ case DECIMAL64:
+ case BITS:
+ case BINARY:
+ case UNION:
+ case ENUMERATION:
+ case DERIVED:
+ return targetDataType + PERIOD + FROM_STRING_METHOD_NAME;
+ default:
+ throw new TranslatorException("given data type is not supported.");
+ }
+ }
}
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/TempJavaCodeFragmentFilesUtils.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/TempJavaCodeFragmentFilesUtils.java
index f70ec53..39620f9 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/TempJavaCodeFragmentFilesUtils.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/TempJavaCodeFragmentFilesUtils.java
@@ -19,51 +19,29 @@
import java.io.File;
import java.io.IOException;
import java.util.List;
-
import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.datamodel.YangNodeIdentifier;
-import org.onosproject.yangutils.translator.exception.TranslatorException;
-import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer;
import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles;
-import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugment;
-import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase;
import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION_IMPORT;
-import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING;
-import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTATION;
import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTATION_HOLDER;
import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO;
-import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
-import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS;
import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT_ANNOTATION_IMPORT;
import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE_ANNOTATION_IMPORT;
-import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION;
import static org.onosproject.yangutils.utils.UtilConstants.ENUM;
-import static org.onosproject.yangutils.utils.UtilConstants.EQUAL;
import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
-import static org.onosproject.yangutils.utils.UtilConstants.IMPL;
-import static org.onosproject.yangutils.utils.UtilConstants.IMPORT;
import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE;
import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_FACTORY_IMPORT;
import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_IMPORT;
-import static org.onosproject.yangutils.utils.UtilConstants.NEW;
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;
-import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
-import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_ANNOTATION_IMPORT;
import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
-import static org.onosproject.yangutils.utils.UtilConstants.THIS;
import static org.onosproject.yangutils.utils.UtilConstants.TYPE;
import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileHandle;
-
import static java.util.Collections.sort;
/**
@@ -121,84 +99,6 @@
}
/**
- * Updated imports with augmented nodes import.
- *
- * @param curNode current YANG node
- * @param imports list of imports
- * @param operation to add or to delete
- */
- public static void addAugmentedNodesImport(YangNode curNode, List<String> imports, boolean operation) {
-
- String nodesImport = "";
-
- if (!(curNode instanceof YangJavaAugment)) {
- throw new TranslatorException("current node should be of type augment node.");
- }
- YangJavaAugment augment = (YangJavaAugment) curNode;
- List<YangNodeIdentifier> targetNodes = augment.getTargetNode();
- YangNode parent = curNode.getParent();
- if (parent instanceof YangJavaModule) {
- // Add impl class import.
- nodesImport = getAugmendtedNodesImports(parent, targetNodes, true) + SEMI_COLAN + NEW_LINE;
- performOperationOnImports(imports, nodesImport, operation);
- // Add builder class import.
- if (targetNodes.size() > 2) {
- nodesImport = getAugmendtedNodesImports(parent, targetNodes, false) + SEMI_COLAN + NEW_LINE;
- performOperationOnImports(imports, nodesImport, operation);
- }
- }
- // TODO: add functionality for submodule and uses.
- }
-
- /**
- * Returns imports for augmented node.
- *
- * @param parent parent YANG node
- * @param targetNodes list of target nodes
- * @param isImplClass if impl class's import required
- * @return imports for augmented node
- */
- private static String getAugmendtedNodesImports(YangNode parent, List<YangNodeIdentifier> targetNodes,
- boolean isImplClass) {
- String pkgInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo().getPackage();
-
- for (int i = 0; i < targetNodes.size() - 1; i++) {
- pkgInfo = pkgInfo + PERIOD + targetNodes.get(i).getName();
- }
- String classInfo = targetNodes.get(targetNodes.size() - 1).getName();
- if (!isImplClass) {
- return IMPORT + pkgInfo.toLowerCase() + PERIOD + getCapitalCase(classInfo) + BUILDER;
- }
- return IMPORT + pkgInfo.toLowerCase() + PERIOD + getCapitalCase(classInfo) + BUILDER + PERIOD
- + getCapitalCase(classInfo) + IMPL;
- }
-
- /**
- * Provides string to be added in augment node's constructor.
- *
- * @param curNode current YANG node
- * @return constructors string
- */
- public static String getAugmentsAddToAugmentedClassString(YangNode curNode) {
-
- if (!(curNode instanceof YangJavaAugment)) {
- throw new TranslatorException("current node should be of type augment node.");
- }
- YangJavaAugment augment = (YangJavaAugment) curNode;
- List<YangNodeIdentifier> targetNodes = augment.getTargetNode();
-
- String name = targetNodes.get(targetNodes.size() - 1).getName();
- String captialCase = getCapitalCase(name);
- String smallCase = getSmallCase(captialCase);
- return EIGHT_SPACE_INDENTATION + captialCase + IMPL + SPACE + smallCase + IMPL + SPACE + EQUAL + SPACE + NEW
- + SPACE + captialCase + BUILDER + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + NEW + SPACE
- + captialCase + IMPL + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE
- + EIGHT_SPACE_INDENTATION + smallCase + IMPL + PERIOD + ADD_STRING + AUGMENTATION + OPEN_PARENTHESIS
- + THIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
-
- }
-
- /**
* Adds import for array list.
*
* @param curNode current YANG node
@@ -227,7 +127,7 @@
* @param classInfo class info to be added to import list
*/
public static void addListnersImport(YangNode curNode, List<String> imports, boolean operation,
- String classInfo) {
+ String classInfo) {
String thisImport = "";
if (classInfo.equals(LISTENER_SERVICE)) {
thisImport = getTempJavaFragement(curNode).getJavaImportData().getListenerServiceImport();
@@ -272,7 +172,7 @@
* @return import list
*/
private static List<String> performOperationOnImports(List<String> imports, String curImport,
- boolean operation) {
+ boolean operation) {
if (operation) {
imports.add(curImport);
} else {
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java
index 7ae17d4..d3e7b09 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java
@@ -25,24 +25,12 @@
import java.util.ArrayList;
import java.util.List;
-import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.translator.exception.TranslatorException;
-import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
-import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
-
-import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getJavaPackageFromPackagePath;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
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.FOUR_SPACE_INDENTATION;
import static org.onosproject.yangutils.utils.UtilConstants.MULTIPLE_NEW_LINE;
import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
-import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.addPackageInfo;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.createDirectories;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
/**
* Represents utility to handle file system operations.
@@ -56,57 +44,13 @@
}
/**
- * Checks if the package directory structure created.
- *
- * @param pkg Package to check if it is created
- * @return existence status of package
- */
- public static boolean doesPackageExist(String pkg) {
- File pkgDir = new File(getPackageDirPathFromJavaJPackage(pkg));
- File pkgWithFile = new File(pkgDir + SLASH + "package-info.java");
- return pkgDir.exists() && pkgWithFile.isFile();
- }
-
- /**
- * Creates a package structure with package info java file if not present.
- *
- * @param yangNode YANG node for which code is being generated
- * @throws IOException any IO exception
- */
- public static void createPackage(YangNode yangNode) throws IOException {
- if (!(yangNode instanceof JavaFileInfoContainer)) {
- throw new TranslatorException("current node must have java file info");
- }
- String pkgInfo;
- JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) yangNode).getJavaFileInfo();
- String pkg = getAbsolutePackagePath(javaFileInfo.getBaseCodeGenPath(), javaFileInfo.getPackageFilePath());
- if (!doesPackageExist(pkg)) {
- try {
- File pack = createDirectories(pkg);
- YangNode parent = getParentNodeInGenCode(yangNode);
- if (parent != null) {
- pkgInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo().getJavaName();
- addPackageInfo(pack, pkgInfo, getJavaPackageFromPackagePath(pkg), true,
- ((JavaFileInfoContainer) parent).getJavaFileInfo().getPluginConfig());
- } else {
- pkgInfo = ((JavaFileInfoContainer) yangNode).getJavaFileInfo().getJavaName();
- addPackageInfo(pack, pkgInfo, getJavaPackageFromPackagePath(pkg), false,
- ((JavaFileInfoContainer) yangNode).getJavaFileInfo().getPluginConfig());
- }
- } catch (IOException e) {
- throw new IOException("failed to create package-info file");
- }
- }
- }
-
- /**
* Reads the contents from source file and append its contents to append
* file.
*
* @param toAppend destination file in which the contents of source file is
- * appended
- * @param srcFile source file from which data is read and added to to append
- * file
+ * appended
+ * @param srcFile source file from which data is read and added to to append
+ * file
* @throws IOException any IO errors
*/
public static void appendFileContents(File toAppend, File srcFile)
@@ -118,7 +62,7 @@
* Reads file and convert it to string.
*
* @param toAppend file to be converted
- * @param spaces spaces to be appended
+ * @param spaces spaces to be appended
* @return string of file
* @throws IOException when fails to convert to string
*/
@@ -153,9 +97,9 @@
/**
* Updates the generated file handle.
*
- * @param inputFile input file
+ * @param inputFile input file
* @param contentTobeAdded content to be appended to the file
- * @param isClose when close of file is called.
+ * @param isClose when close of file is called.
* @throws IOException if the named file exists but is a directory rather than a regular file,
* does not exist but cannot be created, or cannot be opened for any other reason
*/
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
index fb8f981..19660b1 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
@@ -16,10 +16,7 @@
package org.onosproject.yangutils.utils.io.impl;
-import org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
-
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_CLASS_JAVA_DOC;
import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_INTERFACE_JAVA_DOC;
@@ -202,7 +199,7 @@
*/
public static String getJavaDoc(JavaDocType type, String name, boolean isList, YangPluginConfig pluginConfig) {
- name = JavaIdentifierSyntax.getSmallCase(getCamelCase(name, pluginConfig.getConflictResolver()));
+ name = YangIoUtils.getSmallCase(getCamelCase(name, pluginConfig.getConflictResolver()));
switch (type) {
case IMPL_CLASS: {
return generateForClass(name);
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java
index 05cd471..baea6ea 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java
@@ -19,73 +19,60 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.nio.file.Files;
-import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Iterator;
+import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
-import java.util.Set;
import java.util.Stack;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
import java.util.regex.Pattern;
-
import org.apache.commons.io.FileUtils;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.model.Dependency;
-import org.apache.maven.model.Resource;
-import org.apache.maven.project.MavenProject;
-import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.plugin.manager.YangFileInfo;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
-import org.slf4j.Logger;
-import org.sonatype.plexus.build.incremental.BuildContext;
+import org.onosproject.yangutils.translator.exception.TranslatorException;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
+import static org.onosproject.yangutils.utils.UtilConstants.COLAN;
import static org.onosproject.yangutils.utils.UtilConstants.COMMA;
import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.HASH;
import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN;
-import static org.onosproject.yangutils.utils.UtilConstants.JAR;
+import static org.onosproject.yangutils.utils.UtilConstants.JAVA_KEY_WORDS;
import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS;
import static org.onosproject.yangutils.utils.UtilConstants.ORG;
import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE;
import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
+import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_DIGITS_WITH_SINGLE_LETTER;
+import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_FIRST_DIGIT;
+import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_HYPHEN;
+import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_IDENTIFIER_SPECIAL_CHAR;
+import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_PERIOD;
+import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_SINGLE_LETTER;
+import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_UNDERSCORE;
+import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_ALL_SPECIAL_CHAR;
+import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_DIGITS;
+import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_SINGLE_CAPITAL_CASE;
+import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_SINGLE_CAPITAL_CASE_AND_DIGITS_SMALL_CASES;
+import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_UPPERCASE;
import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
-import static org.onosproject.yangutils.utils.UtilConstants.TEMP;
import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION;
-import static org.onosproject.yangutils.utils.UtilConstants.YANG_RESOURCES;
+import static org.onosproject.yangutils.utils.UtilConstants.UNDER_SCORE;
+import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUTO_PREFIX;
import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.appendFileContents;
import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileHandle;
-import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.PACKAGE_INFO;
-import static org.slf4j.LoggerFactory.getLogger;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
/**
* Represents common utility functionalities for code generation.
*/
public final class YangIoUtils {
- private static final Logger log = getLogger(YangIoUtils.class);
- private static final String TARGET_RESOURCE_PATH = SLASH + TEMP + SLASH + YANG_RESOURCES + SLASH;
private static final int LINE_SIZE = 118;
private static final int SUB_LINE_SIZE = 112;
private static final int ZERO = 0;
- private static final String SERIALIZED_FILE_EXTENSION = ".ser";
/**
* Creates an instance of YANG io utils.
@@ -223,19 +210,6 @@
}
/**
- * Adds generated source directory to the compilation root.
- *
- * @param source directory
- * @param project current maven project
- * @param context current build context
- */
- public static void addToCompilationRoot(String source, MavenProject project, BuildContext context) {
- project.addCompileSourceRoot(source);
- context.refresh(project.getBasedir());
- log.info("Source directory added to compilation root: " + source);
- }
-
- /**
* Removes extra char from the string.
*
* @param valueString string to be trimmed
@@ -303,49 +277,6 @@
}
/**
- * Copies YANG files to the current project's output directory.
- *
- * @param yangFileInfo list of YANG files
- * @param outputDir project's output directory
- * @param project maven project
- * @throws IOException when fails to copy files to destination resource directory
- */
- public static void copyYangFilesToTarget(Set<YangFileInfo> yangFileInfo, String outputDir, MavenProject project)
- throws IOException {
-
- List<File> files = getListOfFile(yangFileInfo);
-
- String path = outputDir + TARGET_RESOURCE_PATH;
- File targetDir = new File(path);
- targetDir.mkdirs();
-
- for (File file : files) {
- Files.copy(file.toPath(),
- new File(path + file.getName()).toPath(),
- StandardCopyOption.REPLACE_EXISTING);
- }
- addToProjectResource(outputDir + SLASH + TEMP + SLASH, project);
- }
-
- /**
- * Provides a list of files from list of strings.
- *
- * @param yangFileInfo set of yang file information
- * @return list of files
- */
- private static List<File> getListOfFile(Set<YangFileInfo> yangFileInfo) {
- List<File> files = new ArrayList<>();
- Iterator<YangFileInfo> yangFileIterator = yangFileInfo.iterator();
- while (yangFileIterator.hasNext()) {
- YangFileInfo yangFile = yangFileIterator.next();
- if (yangFile.isForTranslator()) {
- files.add(new File(yangFile.getYangFileName()));
- }
- }
- return files;
- }
-
- /**
* Merges the temp java files to main java files.
*
* @param appendFile temp file
@@ -501,173 +432,258 @@
}
/**
- * Serializes data-model.
+ * Returns the java Package from package path.
*
- * @param directory base directory for serialized files
- * @param fileInfoSet YANG file info set
- * @param project maven project
- * @param operation true if need to add to resource
- * @throws IOException when fails to do IO operations
+ * @param packagePath package path
+ * @return java package
*/
- public static void serializeDataModel(String directory, Set<YangFileInfo> fileInfoSet,
- MavenProject project, boolean operation) throws IOException {
-
- String serFileDirPath = directory + TARGET_RESOURCE_PATH;
- File dir = new File(serFileDirPath);
- dir.mkdirs();
-
- if (operation) {
- addToProjectResource(directory + SLASH + TEMP + SLASH, project);
- }
-
- for (YangFileInfo fileInfo : fileInfoSet) {
-
- String serFileName = serFileDirPath + getCamelCase(fileInfo.getRootNode().getName(), null)
- + SERIALIZED_FILE_EXTENSION;
- fileInfo.setSerializedFile(serFileName);
- FileOutputStream fileOutputStream = new FileOutputStream(serFileName);
- ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
- objectOutputStream.writeObject(fileInfo.getRootNode());
- objectOutputStream.close();
- fileOutputStream.close();
- }
- }
-
- /* Adds directory to resources of project */
- private static void addToProjectResource(String dir, MavenProject project) {
- Resource rsc = new Resource();
- rsc.setDirectory(dir);
- project.addResource(rsc);
+ public static String getJavaPackageFromPackagePath(String packagePath) {
+ return packagePath.replace(SLASH, PERIOD);
}
/**
- * Returns de-serializes YANG data-model nodes.
+ * Returns the directory path corresponding to java package.
*
- * @param serailizedfileInfoSet YANG file info set
- * @return de-serializes YANG data-model nodes
- * @throws IOException when fails do IO operations
+ * @param packagePath package path
+ * @return java package
*/
- public static List<YangNode> deSerializeDataModel(List<String> serailizedfileInfoSet) throws IOException {
-
- List<YangNode> nodes = new ArrayList<>();
- for (String fileInfo : serailizedfileInfoSet) {
- YangNode node = null;
- try {
- FileInputStream fileInputStream = new FileInputStream(fileInfo);
- ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
- node = (YangNode) objectInputStream.readObject();
- nodes.add(node);
- objectInputStream.close();
- fileInputStream.close();
- } catch (IOException | ClassNotFoundException e) {
- throw new IOException(fileInfo + " not found.");
- }
- }
- return nodes;
+ public static String getPackageDirPathFromJavaJPackage(String packagePath) {
+ return packagePath.replace(PERIOD, SLASH);
}
/**
- * Resolves inter jar dependencies.
+ * Returns the YANG identifier name as java identifier with first letter
+ * in small.
*
- * @param project current maven project
- * @param localRepository local maven repository
- * @param remoteRepos list of remote repository
- * @param directory directory for serialized files
- * @return list of resolved datamodel nodes
- * @throws IOException when fails to do IO operations
+ * @param yangIdentifier identifier in YANG file.
+ * @return corresponding java identifier
*/
- public static List<YangNode> resolveInterJarDependencies(MavenProject project, ArtifactRepository localRepository,
- List<ArtifactRepository> remoteRepos, String directory) throws IOException {
-
- List<String> dependeciesJarPaths = resolveDependecyJarPath(project, localRepository, remoteRepos);
- List<YangNode> resolvedDataModelNodes = new ArrayList<>();
- for (String dependecy : dependeciesJarPaths) {
- resolvedDataModelNodes.addAll(deSerializeDataModel(parseJarFile(dependecy, directory)));
- }
- return resolvedDataModelNodes;
+ public static String getSmallCase(String yangIdentifier) {
+ return yangIdentifier.substring(0, 1).toLowerCase() + yangIdentifier.substring(1);
}
/**
- * Returns list of jar path.
+ * Returns the YANG identifier name as java identifier with first letter
+ * in capital.
*
- * @return list of jar paths
+ * @param yangIdentifier identifier in YANG file
+ * @return corresponding java identifier
*/
- private static List<String> resolveDependecyJarPath(MavenProject project, ArtifactRepository localRepository,
- List<ArtifactRepository> remoteRepos) {
-
- StringBuilder path = new StringBuilder();
- List<String> jarPaths = new ArrayList<>();
- for (Dependency dependency : project.getDependencies()) {
-
- path.append(localRepository.getBasedir());
- path.append(SLASH);
- path.append(getPackageDirPathFromJavaJPackage(dependency.getGroupId()));
- path.append(SLASH);
- path.append(dependency.getArtifactId());
- path.append(SLASH);
- path.append(dependency.getVersion());
- path.append(SLASH);
- path.append(dependency.getArtifactId() + HYPHEN + dependency.getVersion() + PERIOD + JAR);
- File jarFile = new File(path.toString());
- if (jarFile.exists()) {
- jarPaths.add(path.toString());
- }
- path.delete(0, path.length());
- }
-
- for (ArtifactRepository repo : remoteRepos) {
- // TODO: add resolver for remote repo.
- }
- return jarPaths;
+ public static String getCapitalCase(String yangIdentifier) {
+ yangIdentifier = yangIdentifier.substring(0, 1).toUpperCase() + yangIdentifier.substring(1);
+ return restrictConsecutiveCapitalCase(yangIdentifier);
}
/**
- * Parses jar file and returns list of serialized file names.
+ * Restricts consecutive capital cased string as a rule in camel case.
*
- * @param jarFile jar file to be parsed
- * @param directory directory for keeping the searized files
- * @return list of serialized files
- * @throws IOException when fails to do IO operations
+ * @param consecCapitalCaseRemover which requires the restriction of consecutive capital case
+ * @return string without consecutive capital case
*/
- public static List<String> parseJarFile(String jarFile, String directory)
- throws IOException {
+ public static String restrictConsecutiveCapitalCase(String consecCapitalCaseRemover) {
- List<String> serailizedFiles = new ArrayList<>();
- JarFile jar = new JarFile(jarFile);
- Enumeration<?> enumEntries = jar.entries();
-
- File serializedFileDir = new File(directory);
- serializedFileDir.mkdirs();
- while (enumEntries.hasMoreElements()) {
- JarEntry file = (JarEntry) enumEntries.nextElement();
- if (file.getName().endsWith(SERIALIZED_FILE_EXTENSION)) {
- if (file.getName().contains(SLASH)) {
- String[] strArray = file.getName().split(SLASH);
- String tempPath = "";
- for (int i = 0; i < strArray.length - 1; i++) {
- tempPath = SLASH + tempPath + SLASH + strArray[i];
+ for (int k = 0; k < consecCapitalCaseRemover.length(); k++) {
+ if (k + 1 < consecCapitalCaseRemover.length()) {
+ if (Character.isUpperCase(consecCapitalCaseRemover.charAt(k))) {
+ if (Character.isUpperCase(consecCapitalCaseRemover.charAt(k + 1))) {
+ consecCapitalCaseRemover = consecCapitalCaseRemover.substring(0, k + 1)
+ + consecCapitalCaseRemover.substring(k + 1, k + 2).toLowerCase()
+ + consecCapitalCaseRemover.substring(k + 2);
}
- File dir = new File(directory + tempPath);
- dir.mkdirs();
}
- File serailizedFile = new File(directory + SLASH + file.getName());
- if (file.isDirectory()) {
- serailizedFile.mkdirs();
- continue;
- }
- InputStream inputStream = jar.getInputStream(file);
-
- FileOutputStream fileOutputStream = new FileOutputStream(serailizedFile);
- while (inputStream.available() > 0) {
- fileOutputStream.write(inputStream.read());
- }
- fileOutputStream.close();
- inputStream.close();
- serailizedFiles.add(serailizedFile.toString());
}
}
- jar.close();
- return serailizedFiles;
+ return consecCapitalCaseRemover;
}
+ /**
+ * Adds prefix, if the string begins with digit or is a java key word.
+ *
+ * @param camelCasePrefix string for adding prefix
+ * @param conflictResolver object of YANG to java naming conflict util
+ * @return prefixed camel case string
+ */
+ public static String addPrefix(String camelCasePrefix, YangToJavaNamingConflictUtil conflictResolver) {
+
+ String prefix = getPrefixForIdentifier(conflictResolver);
+ if (camelCasePrefix.matches(REGEX_FOR_FIRST_DIGIT)) {
+ camelCasePrefix = prefix + camelCasePrefix;
+ }
+ if (JAVA_KEY_WORDS.contains(camelCasePrefix)) {
+ camelCasePrefix = prefix + camelCasePrefix.substring(0, 1).toUpperCase()
+ + camelCasePrefix.substring(1);
+ }
+ return camelCasePrefix;
+ }
+
+ /**
+ * Applies the rule that a string does not end with a capitalized letter and capitalizes
+ * the letter next to a number in an array.
+ *
+ * @param stringArray containing strings for camel case separation
+ * @param conflictResolver object of YANG to java naming conflict util
+ * @return camel case rule checked string
+ */
+ public static String applyCamelCaseRule(String[] stringArray, YangToJavaNamingConflictUtil conflictResolver) {
+
+ String ruleChecker = stringArray[0].toLowerCase();
+ int i;
+ if (ruleChecker.matches(REGEX_FOR_FIRST_DIGIT)) {
+ i = 0;
+ ruleChecker = EMPTY_STRING;
+ } else {
+ i = 1;
+ }
+ for (; i < stringArray.length; i++) {
+ if (i + 1 == stringArray.length) {
+ if (stringArray[i].matches(REGEX_FOR_SINGLE_LETTER)
+ || stringArray[i].matches(REGEX_FOR_DIGITS_WITH_SINGLE_LETTER)) {
+ ruleChecker = ruleChecker + stringArray[i].toLowerCase();
+ break;
+ }
+ }
+ if (stringArray[i].matches(REGEX_FOR_FIRST_DIGIT)) {
+ for (int j = 0; j < stringArray[i].length(); j++) {
+ char letterCheck = stringArray[i].charAt(j);
+ if (Character.isLetter(letterCheck)) {
+ stringArray[i] = stringArray[i].substring(0, j)
+ + stringArray[i].substring(j, j + 1).toUpperCase() + stringArray[i].substring(j + 1);
+ break;
+ }
+ }
+ ruleChecker = ruleChecker + stringArray[i];
+ } else {
+ ruleChecker = ruleChecker + stringArray[i].substring(0, 1).toUpperCase() + stringArray[i].substring(1);
+ }
+ }
+ String ruleCheckerWithPrefix = addPrefix(ruleChecker, conflictResolver);
+ return restrictConsecutiveCapitalCase(ruleCheckerWithPrefix);
+ }
+
+ /**
+ * Resolves the conflict when input has upper case.
+ *
+ * @param stringArray containing strings for upper case conflict resolver
+ * @param conflictResolver object of YANG to java naming conflict util
+ * @return camel cased string
+ */
+ public static String upperCaseConflictResolver(String[] stringArray,
+ YangToJavaNamingConflictUtil conflictResolver) {
+
+ for (int l = 0; l < stringArray.length; l++) {
+ String[] upperCaseSplitArray = stringArray[l].split(REGEX_WITH_UPPERCASE);
+ for (int m = 0; m < upperCaseSplitArray.length; m++) {
+ if (upperCaseSplitArray[m].matches(REGEX_WITH_SINGLE_CAPITAL_CASE)) {
+ int check = m;
+ while (check + 1 < upperCaseSplitArray.length) {
+ if (upperCaseSplitArray[check + 1].matches(REGEX_WITH_SINGLE_CAPITAL_CASE)) {
+ upperCaseSplitArray[check + 1] = upperCaseSplitArray[check + 1].toLowerCase();
+ check = check + 1;
+ } else if (upperCaseSplitArray[check + 1]
+ .matches(REGEX_WITH_SINGLE_CAPITAL_CASE_AND_DIGITS_SMALL_CASES)) {
+ upperCaseSplitArray[check + 1] = upperCaseSplitArray[check + 1].toLowerCase();
+ break;
+ } else {
+ break;
+ }
+ }
+ }
+ }
+ StringBuilder strBuilder = new StringBuilder();
+ for (String element : upperCaseSplitArray) {
+ strBuilder.append(element);
+ }
+ stringArray[l] = strBuilder.toString();
+ }
+ List<String> result = new ArrayList<String>();
+ for (String element : stringArray) {
+ String[] capitalCaseSplitArray = element.split(REGEX_WITH_UPPERCASE);
+ for (String letter : capitalCaseSplitArray) {
+ String[] arrayForAddition = letter.split(REGEX_WITH_DIGITS);
+ List<String> list = Arrays.asList(arrayForAddition);
+ for (String str : list) {
+ if (str != null && !str.isEmpty()) {
+ result.add(str);
+ }
+ }
+ }
+ }
+ stringArray = result.toArray(new String[result.size()]);
+ return applyCamelCaseRule(stringArray, conflictResolver);
+ }
+
+ /**
+ * Returns the YANG identifier name as java identifier.
+ *
+ * @param yangIdentifier identifier in YANG file
+ * @param conflictResolver object of YANG to java naming conflict util
+ * @return corresponding java identifier
+ */
+ public static String getCamelCase(String yangIdentifier, YangToJavaNamingConflictUtil conflictResolver) {
+
+ if (conflictResolver != null) {
+ String replacementForHyphen = conflictResolver.getReplacementForHyphen();
+ String replacementForPeriod = conflictResolver.getReplacementForPeriod();
+ String replacementForUnderscore = conflictResolver.getReplacementForUnderscore();
+ if (replacementForPeriod != null) {
+ yangIdentifier = yangIdentifier.replaceAll(REGEX_FOR_PERIOD,
+ PERIOD + replacementForPeriod.toLowerCase() + PERIOD);
+ }
+ if (replacementForUnderscore != null) {
+ yangIdentifier = yangIdentifier.replaceAll(REGEX_FOR_UNDERSCORE,
+ UNDER_SCORE + replacementForUnderscore.toLowerCase() + UNDER_SCORE);
+ }
+ if (replacementForHyphen != null) {
+ yangIdentifier = yangIdentifier.replaceAll(REGEX_FOR_HYPHEN,
+ HYPHEN + replacementForHyphen.toLowerCase() + HYPHEN);
+ }
+ }
+ yangIdentifier = yangIdentifier.replaceAll(REGEX_FOR_IDENTIFIER_SPECIAL_CHAR, COLAN);
+ String[] strArray = yangIdentifier.split(COLAN);
+ if (strArray[0].isEmpty()) {
+ List<String> stringArrangement = new ArrayList<String>();
+ for (int i = 1; i < strArray.length; i++) {
+ stringArrangement.add(strArray[i]);
+ }
+ strArray = stringArrangement.toArray(new String[stringArrangement.size()]);
+ }
+ return upperCaseConflictResolver(strArray, conflictResolver);
+ }
+
+ /**
+ * Prefix for adding with identifier and namespace, when it is a java keyword or starting with digits.
+ *
+ * @param conflictResolver object of YANG to java naming conflict util
+ * @return prefix which needs to be added
+ */
+ public static String getPrefixForIdentifier(YangToJavaNamingConflictUtil conflictResolver) {
+
+ String prefixForIdentifier = null;
+ if (conflictResolver != null) {
+ prefixForIdentifier = conflictResolver.getPrefixForIdentifier();
+ }
+ if (prefixForIdentifier != null) {
+ prefixForIdentifier = prefixForIdentifier.replaceAll(REGEX_WITH_ALL_SPECIAL_CHAR, COLAN);
+ String[] strArray = prefixForIdentifier.split(COLAN);
+ try {
+ if (strArray[0].isEmpty()) {
+ List<String> stringArrangement = new ArrayList<String>();
+ for (int i = 1; i < strArray.length; i++) {
+ stringArrangement.add(strArray[i]);
+ }
+ strArray = stringArrangement.toArray(new String[stringArrangement.size()]);
+ }
+ prefixForIdentifier = strArray[0];
+ for (int j = 1; j < strArray.length; j++) {
+ prefixForIdentifier = prefixForIdentifier + strArray[j].substring(0, 1).toUpperCase() +
+ strArray[j].substring(1);
+ }
+ } catch (ArrayIndexOutOfBoundsException outOfBoundsException) {
+ throw new TranslatorException("The given prefix in pom.xml is invalid.");
+ }
+ } else {
+ prefixForIdentifier = YANG_AUTO_PREFIX;
+ }
+ return prefixForIdentifier;
+ }
}
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangPluginConfig.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangPluginConfig.java
similarity index 96%
rename from utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangPluginConfig.java
rename to utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangPluginConfig.java
index f827698..21314ef 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangPluginConfig.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangPluginConfig.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.translator.tojava.utils;
+package org.onosproject.yangutils.utils.io.impl;
/**
* Representation of plugin configurations required for YANG utils.
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangToJavaNamingConflictUtil.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangToJavaNamingConflictUtil.java
similarity index 97%
rename from utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangToJavaNamingConflictUtil.java
rename to utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangToJavaNamingConflictUtil.java
index 4f701b6..d7b32e9 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangToJavaNamingConflictUtil.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangToJavaNamingConflictUtil.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.translator.tojava.utils;
+package org.onosproject.yangutils.utils.io.impl;
/**
* Representation of YANG to java naming conflict resolver util.
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/ietfyang/IetfYangFileTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/ietfyang/IetfYangFileTest.java
index 0f0a514..49c5d60 100644
--- a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/ietfyang/IetfYangFileTest.java
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/ietfyang/IetfYangFileTest.java
@@ -22,7 +22,7 @@
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import org.onosproject.yangutils.plugin.manager.YangUtilManager;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
import java.io.IOException;
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/InterFileLinkingTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/InterFileLinkingTest.java
index fd7b8ad..eda4873 100644
--- a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/InterFileLinkingTest.java
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/InterFileLinkingTest.java
@@ -34,10 +34,9 @@
import org.onosproject.yangutils.linker.impl.YangLinkerManager;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
-import org.onosproject.yangutils.plugin.manager.YangFileInfo;
import org.onosproject.yangutils.plugin.manager.YangUtilManager;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -67,29 +66,30 @@
String searchDir = "src/test/resources/interfiletype";
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
YangNode refNode = null;
YangNode selfNode = null;
// Create YANG node set
- yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
// Add references to import list.
- yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
// Carry out inter-file linking.
- yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet());
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
- Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator();
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
- YangFileInfo yangFileInfo = yangFileInfoIterator.next();
+ YangNode rootNode = yangNodeIterator.next();
- if (yangFileInfo.getRootNode().getName().equals("module1")) {
- selfNode = yangFileInfo.getRootNode();
- refNode = yangFileInfoIterator.next().getRootNode();
+ if (rootNode.getName().equals("module1")) {
+ selfNode = rootNode;
+ refNode = yangNodeIterator.next();
} else {
- refNode = yangFileInfo.getRootNode();
- selfNode = yangFileInfoIterator.next().getRootNode();
+ refNode = rootNode;
+ selfNode = yangNodeIterator.next();
}
// Check whether the data model tree returned is of type module.
@@ -136,29 +136,30 @@
String searchDir = "src/test/resources/interfileuses";
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
YangNode refNode = null;
YangNode selfNode = null;
// Create YANG node set
- yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
// Add references to import list.
- yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
// Carry out inter-file linking.
- yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet());
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
- Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator();
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
- YangFileInfo yangFileInfo = yangFileInfoIterator.next();
+ YangNode rootNode = yangNodeIterator.next();
- if (yangFileInfo.getRootNode().getName().equals("module1")) {
- selfNode = yangFileInfo.getRootNode();
- refNode = yangFileInfoIterator.next().getRootNode();
+ if (rootNode.getName().equals("module1")) {
+ selfNode = rootNode;
+ refNode = yangNodeIterator.next();
} else {
- refNode = yangFileInfo.getRootNode();
- selfNode = yangFileInfoIterator.next().getRootNode();
+ refNode = rootNode;
+ selfNode = yangNodeIterator.next();
}
// Check whether the data model tree returned is of type module.
@@ -193,14 +194,6 @@
// Check whether uses get resolved.
assertThat(uses.getResolvableStatus(),
is(ResolvableStatus.RESOLVED));
-
-// leafIterator = yangNode.getListOfLeaf().listIterator();
-// leafInfo = leafIterator.next();
-//
-// // Check whether the information in the leaf is correct under module.
-// assertThat(leafInfo.getName(), is("hello"));
-// assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
-// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
}
/**
@@ -213,32 +206,33 @@
String searchDir = "src/test/resources/interfiletypewithinclude";
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
YangNode refNode = null;
YangNode selfNode = null;
// Create YANG node set
- yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
// Carry out linking of sub module with module.
- yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangFileInfoSet());
+ yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
// Add reference to include list.
- yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangFileInfoSet());
+ yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
// Carry out inter-file linking.
- yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet());
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
- Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator();
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
- YangFileInfo yangFileInfo = yangFileInfoIterator.next();
+ YangNode rootNode = yangNodeIterator.next();
- if (yangFileInfo.getRootNode().getName().equals("module1")) {
- selfNode = yangFileInfo.getRootNode();
- refNode = yangFileInfoIterator.next().getRootNode();
+ if (rootNode.getName().equals("module1")) {
+ selfNode = rootNode;
+ refNode = yangNodeIterator.next();
} else {
- refNode = yangFileInfo.getRootNode();
- selfNode = yangFileInfoIterator.next().getRootNode();
+ refNode = rootNode;
+ selfNode = yangNodeIterator.next();
}
// Check whether the data model tree returned is of type module.
@@ -285,32 +279,33 @@
String searchDir = "src/test/resources/interfileuseswithinclude";
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
YangNode refNode = null;
YangNode selfNode = null;
// Create YANG node set
- yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
// Carry out linking of sub module with module.
- yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangFileInfoSet());
+ yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
// Add reference to include list.
- yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangFileInfoSet());
+ yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
// Carry out inter-file linking.
- yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet());
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
- Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator();
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
- YangFileInfo yangFileInfo = yangFileInfoIterator.next();
+ YangNode rootNode = yangNodeIterator.next();
- if (yangFileInfo.getRootNode().getName().equals("module1")) {
- selfNode = yangFileInfo.getRootNode();
- refNode = yangFileInfoIterator.next().getRootNode();
+ if (rootNode.getName().equals("module1")) {
+ selfNode = rootNode;
+ refNode = yangNodeIterator.next();
} else {
- refNode = yangFileInfo.getRootNode();
- selfNode = yangFileInfoIterator.next().getRootNode();
+ refNode = rootNode;
+ selfNode = yangNodeIterator.next();
}
// Check whether the data model tree returned is of type module.
@@ -345,14 +340,6 @@
// Check whether uses get resolved.
assertThat(uses.getResolvableStatus(),
is(ResolvableStatus.RESOLVED));
-
-// leafIterator = yangNode.getListOfLeaf().listIterator();
-// leafInfo = leafIterator.next();
-//
-// // Check whether the information in the leaf is correct under module.
-// assertThat(leafInfo.getName(), is("hello"));
-// assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
-// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
}
/**
@@ -365,29 +352,30 @@
String searchDir = "src/test/resources/interfiletypewithrevision";
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
YangNode refNode = null;
YangNode selfNode = null;
// Create YANG node set
- yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
// Add references to import list.
- yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
// Carry out inter-file linking.
- yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet());
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
- Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator();
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
- YangFileInfo yangFileInfo = yangFileInfoIterator.next();
+ YangNode rootNode = yangNodeIterator.next();
- if (yangFileInfo.getRootNode().getName().equals("module1")) {
- selfNode = yangFileInfo.getRootNode();
- refNode = yangFileInfoIterator.next().getRootNode();
+ if (rootNode.getName().equals("module1")) {
+ selfNode = rootNode;
+ refNode = yangNodeIterator.next();
} else {
- refNode = yangFileInfo.getRootNode();
- selfNode = yangFileInfoIterator.next().getRootNode();
+ refNode = rootNode;
+ selfNode = yangNodeIterator.next();
}
// Check whether the data model tree returned is of type module.
@@ -434,29 +422,30 @@
String searchDir = "src/test/resources/interfiletypewithrevisioninname";
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
YangNode refNode = null;
YangNode selfNode = null;
// Create YANG node set
- yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
// Add references to import list.
- yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
// Carry out inter-file linking.
- yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet());
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
- Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator();
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
- YangFileInfo yangFileInfo = yangFileInfoIterator.next();
+ YangNode rootNode = yangNodeIterator.next();
- if (yangFileInfo.getRootNode().getName().equals("module1")) {
- selfNode = yangFileInfo.getRootNode();
- refNode = yangFileInfoIterator.next().getRootNode();
+ if (rootNode.getName().equals("module1")) {
+ selfNode = rootNode;
+ refNode = yangNodeIterator.next();
} else {
- refNode = yangFileInfo.getRootNode();
- selfNode = yangFileInfoIterator.next().getRootNode();
+ refNode = rootNode;
+ selfNode = yangNodeIterator.next();
}
// Check whether the data model tree returned is of type module.
@@ -503,27 +492,28 @@
String searchDir = "src/test/resources/hierarchicalinterfiletype";
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
YangNode refNode1 = null;
YangNode refNode2 = null;
YangNode selfNode = null;
// Create YANG node set
- yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
// Add references to import list.
- yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
// Carry out inter-file linking.
- yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet());
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
- for (YangFileInfo yangFile : utilManager.getYangFileInfoSet()) {
- if (yangFile.getRootNode().getName().equals("ietf-network-topology")) {
- selfNode = yangFile.getRootNode();
- } else if (yangFile.getRootNode().getName().equals("ietf-network")) {
- refNode1 = yangFile.getRootNode();
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("ietf-network-topology")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("ietf-network")) {
+ refNode1 = rootNode;
} else {
- refNode2 = yangFile.getRootNode();
+ refNode2 = rootNode;
}
}
@@ -571,24 +561,25 @@
String searchDir = "src/test/resources/hierarchicalintrawithinterfiletype";
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
YangNode refNode1 = null;
YangNode selfNode = null;
// Create YANG node set
- yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
// Add references to import list.
- yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
// Carry out inter-file linking.
- yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet());
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
- for (YangFileInfo yangFile : utilManager.getYangFileInfoSet()) {
- if (yangFile.getRootNode().getName().equals("ietf-network")) {
- selfNode = yangFile.getRootNode();
- } else if (yangFile.getRootNode().getName().equals("ietf-inet-types")) {
- refNode1 = yangFile.getRootNode();
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("ietf-network")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("ietf-inet-types")) {
+ refNode1 = rootNode;
}
}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/InterJarLinkingTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/InterJarLinkingTest.java
deleted file mode 100644
index 39b03fe..0000000
--- a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/InterJarLinkingTest.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * 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.linker;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.junit.Test;
-import org.onosproject.yangutils.datamodel.YangContainer;
-import org.onosproject.yangutils.datamodel.YangDerivedInfo;
-import org.onosproject.yangutils.datamodel.YangGrouping;
-import org.onosproject.yangutils.datamodel.YangLeaf;
-import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.plugin.manager.YangFileInfo;
-import org.onosproject.yangutils.plugin.manager.YangUtilManager;
-import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
-import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
-import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deSerializeDataModel;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.parseJarFile;
-
-/**
- * Unit test case for inter-jar linker.
- */
-public class InterJarLinkingTest {
-
- private final YangUtilManager utilManager = new YangUtilManager();
-
- private static final String TARGET = "target/interJarFileLinking";
- private static final String SEARCH_DIR_FOR_YANG_FILES = "src/test/resources/interJarFileLinking/yangFiles";
- private static final String SEARCH_DIR_FOR_SINGLE_JAR_FILES = "src/test/resources/interJarFileLinking/"
- + "jarFiles/single";
- private static final String SEARCH_DIR_FOR_MULTI_JAR_FILES = "src/test/resources/interJarFileLinking/"
- + "jarFiles/multi";
-
- /**
- * Unit test case for a single jar dependency.
- *
- * @throws IOException when fails to do IO operations
- * @throws MojoExecutionException when fails to do mojo operations
- */
- @Test
- public void processSingleJarLinking()
- throws IOException, MojoExecutionException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(SEARCH_DIR_FOR_YANG_FILES));
-
- int size1 = utilManager.getYangFileInfoSet().size();
-
- for (String file : getListOfTestJar(SEARCH_DIR_FOR_SINGLE_JAR_FILES)) {
- addInterJarRootNodes(file);
- }
-
- utilManager.parseYangFileInfoSet();
-
- utilManager.resolveDependenciesUsingLinker();
-
- Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator();
-
- YangFileInfo yangFileInfo = yangFileInfoIterator.next();
-
- int size2 = utilManager.getYangFileInfoSet().size();
- assertThat(true, is(size1 != size2));
- assertThat(true, is(yangFileInfo.getRootNode().getName().equals("port-pair")));
-
- deleteDirectory(TARGET);
-
- }
-
- /**
- * Unit test case for a multiple jar dependency.
- *
- * @throws IOException when fails to do IO operations
- * @throws MojoExecutionException when fails to do mojo operations
- */
- @Test
- public void processMultipleJarLinking()
- throws IOException, MojoExecutionException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(SEARCH_DIR_FOR_YANG_FILES));
-
- int size1 = utilManager.getYangFileInfoSet().size();
-
- for (String file : getListOfTestJar(SEARCH_DIR_FOR_MULTI_JAR_FILES)) {
- addInterJarRootNodes(file);
- }
-
- utilManager.parseYangFileInfoSet();
-
- utilManager.resolveDependenciesUsingLinker();
-
- Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator();
-
- YangFileInfo yangFileInfo = yangFileInfoIterator.next();
-
- int size2 = utilManager.getYangFileInfoSet().size();
- assertThat(true, is(size1 != size2));
- assertThat(true, is(yangFileInfo.getRootNode().getName().equals("port-pair")));
-
- yangFileInfo = yangFileInfoIterator.next();
- assertThat(true, is(yangFileInfo.getRootNode().getName().equals("flow-classifier")));
-
- /*
- * grouping flow-classifier {
- * container flow-classifier {
- * leaf id {
- * type flow-classifier-id;
- * }
- *
- * leaf tenant-id {
- * type port-pair:tenant-id;
- * }
- * .
- * .
- * .
- *
- */
-
- YangNode node = yangFileInfo.getRootNode();
- node = node.getChild();
- while (node != null) {
- if (node instanceof YangGrouping) {
- break;
- }
- node = node.getNextSibling();
- }
-
- node = node.getChild();
- ListIterator<YangLeaf> leafIterator = ((YangContainer) node).getListOfLeaf().listIterator();
- YangLeaf leafInfo = leafIterator.next();
-
- assertThat(leafInfo.getName(), is("id"));
- assertThat(leafInfo.getDataType().getDataTypeName(), is("flow-classifier-id"));
- assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
-
- leafInfo = leafIterator.next();
-
- assertThat(leafInfo.getName(), is("tenant-id"));
- assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
-
- assertThat(true, is(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef()
- .getName().equals("tenant-id")));
-
- assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
-
- YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
-
- // Check for the effective built-in type.
- assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
-
- deleteDirectory(TARGET);
- }
-
- /**
- * Returns list of test jar files.
- *
- * @param searchdir search directory
- * @return list of test jar files
- */
- private List<String> getListOfTestJar(String searchdir) {
- List<String> jarFiles = new ArrayList<>();
-
- File directory = new File(searchdir + "/");
- File[] files = directory.listFiles();
-
- for (File file : files) {
- jarFiles.add(file.toString());
- }
-
- return jarFiles;
- }
-
- /**
- * Adds data model nodes of jar to file info set.
- *
- * @param jarFile jar file name
- * @throws IOException when fails to do IO operations
- */
- private void addInterJarRootNodes(String jarFile) throws IOException {
- try {
- List<YangNode> interJarResolvedNodes = deSerializeDataModel(parseJarFile(jarFile, TARGET));
-
- for (YangNode node : interJarResolvedNodes) {
- YangFileInfo dependentFileInfo = new YangFileInfo();
- dependentFileInfo.setRootNode(node);
- dependentFileInfo.setForTranslator(false);
- dependentFileInfo.setYangFileName(node.getName());
- utilManager.getYangFileInfoSet().add(dependentFileInfo);
- }
- } catch (IOException e) {
- throw new IOException("failed to resolve in interjar scenario.");
- }
- }
-
-}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/IntraFileUsesLinkingTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/IntraFileUsesLinkingTest.java
index e960d62..c74da32 100644
--- a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/IntraFileUsesLinkingTest.java
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/IntraFileUsesLinkingTest.java
@@ -17,6 +17,7 @@
package org.onosproject.yangutils.linker;
import java.io.IOException;
+import java.util.List;
import java.util.ListIterator;
import org.junit.Rule;
import org.junit.Test;
@@ -92,13 +93,15 @@
assertThat(uses.getResolvableStatus(),
is(ResolvableStatus.RESOLVED));
-// leafIterator = yangNode.getListOfLeaf().listIterator();
-// leafInfo = leafIterator.next();
-//
-// // Check whether the information in the leaf is correct under module.
-// assertThat(leafInfo.getName(), is("hello"));
-// assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
-// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+ ListIterator<List<YangLeaf>> leafIterator1 = uses.getUsesResolvedLeavesList().listIterator();
+ List<YangLeaf> leafInfo1 = leafIterator1.next();
+ ListIterator<YangLeaf> leafIterator2 = leafInfo1.listIterator();
+ YangLeaf leafInfo2 = leafIterator2.next();
+
+ // Check whether the information in the leaf is correct under module.
+ assertThat(leafInfo2.getName(), is("hello"));
+ assertThat(leafInfo2.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo2.getDataType().getDataType(), is(YangDataTypes.STRING));
}
@@ -161,28 +164,32 @@
assertThat(uses.getResolvableStatus(),
is(ResolvableStatus.RESOLVED));
-// leafIterator = yangNode.getListOfLeaf().listIterator();
-// leafInfo = leafIterator.next();
-//
-// // Check whether the information in the leaf is correct under module.
-// assertThat(leafInfo.getName(), is("treat"));
-// assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
-// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+ ListIterator<List<YangLeaf>> leafIterator1 = uses.getUsesResolvedLeavesList().listIterator();
+ List<YangLeaf> leafInfo1 = leafIterator1.next();
+ ListIterator<YangLeaf> leafIterator2 = leafInfo1.listIterator();
+ YangLeaf leafInfo2 = leafIterator2.next();
-// // Check whether container is the child of module.
-// assertThat((grouping.getNextSibling() instanceof YangContainer), is(true));
-// container = (YangContainer) grouping.getNextSibling();
-//
-// // Check whether the container name is set correctly which is under module.
-// assertThat(container.getName(), is("test"));
-//
-// leafIterator = container.getListOfLeaf().listIterator();
-// leafInfo = leafIterator.next();
-//
-// // Check whether the information in the leaf is correct under container which is under module.
-// assertThat(leafInfo.getName(), is("leaf2"));
-// assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
-// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+ // Check whether the information in the leaf is correct under module.
+ assertThat(leafInfo2.getName(), is("treat"));
+ assertThat(leafInfo2.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo2.getDataType().getDataType(), is(YangDataTypes.STRING));
+
+ ListIterator<YangNode> usesChildren = uses.getUsesResolvedNodeList().listIterator();
+ YangNode usesChild = usesChildren.next();
+ // Check whether container is the child of module.
+ assertThat((usesChild instanceof YangContainer), is(true));
+ container = (YangContainer) usesChild;
+
+ // Check whether the container name is set correctly which is under module.
+ assertThat(container.getName(), is("test"));
+
+ leafIterator = container.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under container which is under module.
+ assertThat(leafInfo.getName(), is("leaf2"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
}
/**
@@ -241,52 +248,56 @@
assertThat(uses.getResolvableStatus(),
is(ResolvableStatus.RESOLVED));
-// // Check whether list is the sibling of uses which has been deep copied from grouping.
-// assertThat((yangNode.getChild().getChild().getNextSibling().getChild().getNextSibling() instanceof YangList),
-// is(true));
-// YangList yangList = (YangList) yangNode.getChild().getChild().getNextSibling().getChild().getNextSibling();
-//
-// // Check whether the list name is set correctly.
-// assertThat(yangList.getName(), is("valid"));
-//
-// leafIterator = yangList.getListOfLeaf().listIterator();
-// leafInfo = leafIterator.next();
-//
-// // Check whether the information in the leaf is correct under list which is deep copied.
-// assertThat(leafInfo.getName(), is("invalid-interval"));
-// assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
-// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
-// assertThat(leafInfo.getUnits(), is("\"seconds\""));
-// assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
-//
-// // Check whether uses is output's child.
-// assertThat((yangNode.getChild().getChild().getNextSibling().getNextSibling().getChild() instanceof YangUses),
-// is(true));
-// YangUses usesInOuput = (YangUses) yangNode.getChild().getChild().getNextSibling().getNextSibling().getChild();
-//
-// // Check whether uses get resolved.
-// assertThat(usesInOuput.getResolvableStatus(),
-// is(ResolvableStatus.RESOLVED));
-//
-// // Check whether list is the sibling of uses which has been deep copied from grouping.
-// assertThat((yangNode.getChild().getChild().getNextSibling().getChild().getNextSibling() instanceof YangList),
-// is(true));
-//
-// YangList yangListInOutput = (YangList) yangNode.getChild().getChild().getNextSibling().getNextSibling()
-// .getChild().getNextSibling();
-//
-// // Check whether the list name is set correctly.
-// assertThat(yangListInOutput.getName(), is("valid"));
-//
-// leafIterator = yangListInOutput.getListOfLeaf().listIterator();
-// leafInfo = leafIterator.next();
-//
-// // Check whether the information in the leaf is correct under list which is deep copied.
-// assertThat(leafInfo.getName(), is("invalid-interval"));
-// assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
-// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
-// assertThat(leafInfo.getUnits(), is("\"seconds\""));
-// assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ ListIterator<YangNode> usesChildren = uses.getUsesResolvedNodeList().listIterator();
+ YangNode usesChild = usesChildren.next();
+
+ // Check whether list is the sibling of uses which has been deep copied from grouping.
+ assertThat((usesChild instanceof YangList), is(true));
+
+ YangList yangList = (YangList) usesChild;
+
+ // Check whether the list name is set correctly.
+ assertThat(yangList.getName(), is("valid"));
+
+ leafIterator = yangList.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under list which is deep copied.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+
+ // Check whether uses is output's child.
+ assertThat((yangNode.getChild().getChild().getNextSibling().getNextSibling().getChild() instanceof YangUses),
+ is(true));
+ YangUses usesInOuput = (YangUses) yangNode.getChild().getChild().getNextSibling().getNextSibling().getChild();
+
+ // Check whether uses get resolved.
+ assertThat(usesInOuput.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ ListIterator<YangNode> usesInOuputChildren = usesInOuput.getUsesResolvedNodeList().listIterator();
+ YangNode usesInOuputChild = usesInOuputChildren.next();
+
+ // Check whether list is the sibling of uses which has been deep copied from grouping.
+ assertThat((usesInOuputChild instanceof YangList), is(true));
+
+ YangList yangListInOutput = (YangList) usesInOuputChild;
+
+ // Check whether the list name is set correctly.
+ assertThat(yangListInOutput.getName(), is("valid"));
+
+ leafIterator = yangListInOutput.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under list which is deep copied.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
}
/**
@@ -342,6 +353,24 @@
assertThat(firstUses.getResolvableStatus(),
is(ResolvableStatus.RESOLVED));
+ ListIterator<YangNode> firstUsesChildren = firstUses.getUsesResolvedNodeList().listIterator();
+ YangNode firstUsesChild = firstUsesChildren.next();
+
+ // Check whether list is the sibling of uses.
+ assertThat((firstUsesChild instanceof YangList), is(true));
+ YangList yangList = (YangList) firstUsesChild;
+ assertThat(yangList.getName(), is("valid"));
+
+ leafIterator = yangList.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under list which has been deep copied from grouping.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+
// Check whether container is the sibling of uses.
assertThat((firstUses.getNextSibling() instanceof YangContainer), is(true));
YangContainer yangContainer = (YangContainer) firstUses.getNextSibling();
@@ -349,14 +378,6 @@
// Check whether the container name is set correctly.
assertThat(yangContainer.getName(), is("design"));
-// leafIterator = yangContainer.getListOfLeaf().listIterator();
-// leafInfo = leafIterator.next();
-//
-// // Check whether the information in the leaf is correct under design-container.
-// assertThat(leafInfo.getName(), is("ink"));
-// assertThat(leafInfo.getDataType().getDataTypeName(), is("int32"));
-// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.INT32));
-
// Check whether uses is design-container's child.
assertThat((yangContainer.getChild() instanceof YangUses), is(true));
YangUses secondUses = (YangUses) yangContainer.getChild();
@@ -365,6 +386,16 @@
assertThat(secondUses.getResolvableStatus(),
is(ResolvableStatus.RESOLVED));
+ ListIterator<List<YangLeaf>> leafIterator1 = secondUses.getUsesResolvedLeavesList().listIterator();
+ List<YangLeaf> leafInfo1 = leafIterator1.next();
+ ListIterator<YangLeaf> leafIterator2 = leafInfo1.listIterator();
+ YangLeaf leafInfo2 = leafIterator2.next();
+
+ // Check whether the information in the leaf is correct under design-container.
+ assertThat(leafInfo2.getName(), is("ink"));
+ assertThat(leafInfo2.getDataType().getDataTypeName(), is("int32"));
+ assertThat(leafInfo2.getDataType().getDataType(), is(YangDataTypes.INT32));
+
// Check whether container is the sibling of uses.
assertThat((secondUses.getNextSibling() instanceof YangContainer), is(true));
YangContainer yangContainer2 = (YangContainer) secondUses.getNextSibling();
@@ -386,85 +417,88 @@
assertThat(thirdUses.getResolvableStatus(),
is(ResolvableStatus.RESOLVED));
-// // Check whether container is the sibling of uses.
-// assertThat((thirdUses.getNextSibling() instanceof YangContainer), is(true));
-//
-// YangContainer yangContainer3 = (YangContainer) thirdUses.getNextSibling();
-// assertThat(yangContainer3.getName(), is("value"));
-//
-// leafIterator = yangContainer3.getListOfLeaf().listIterator();
-// leafInfo = leafIterator.next();
-//
-// // Check whether the information in the leaf is correct under container
-// // which has been deep copied from grouping.
-// assertThat(leafInfo.getName(), is("zip-code"));
-// assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
-// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
-//
-// // Check whether uses is the sibling of container-design.
-// assertThat((yangContainer.getNextSibling() instanceof YangUses), is(true));
-// YangUses fourthUses = (YangUses) yangContainer.getNextSibling();
-//
-// // Check whether uses get resolved.
-// assertThat(fourthUses.getResolvableStatus(),
-// is(ResolvableStatus.RESOLVED));
-//
-// // Check whether uses is the sibling of previous uses.
-// assertThat((fourthUses.getNextSibling() instanceof YangUses), is(true));
-// YangUses fifthUses = (YangUses) fourthUses.getNextSibling();
-//
-// // Check whether uses get resolved.
-// assertThat(fifthUses.getResolvableStatus(),
-// is(ResolvableStatus.RESOLVED));
-//
-// // Check whether list is the sibling of uses.
-// assertThat((fifthUses.getNextSibling() instanceof YangList), is(true));
-// YangList yangList = (YangList) fifthUses.getNextSibling();
-// assertThat(yangList.getName(), is("valid"));
-//
-// leafIterator = yangList.getListOfLeaf().listIterator();
-// leafInfo = leafIterator.next();
-//
-// // Check whether the information in the leaf is correct under list which has been deep copied from grouping.
-// assertThat(leafInfo.getName(), is("invalid-interval"));
-// assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
-// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
-// assertThat(leafInfo.getUnits(), is("\"seconds\""));
-// assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
-//
-// // Check whether typedef is the sibling of list.
-// assertThat((yangList.getNextSibling() instanceof YangTypeDef), is(true));
-// YangTypeDef yangTypeDef = (YangTypeDef) yangList.getNextSibling();
-// assertThat(yangTypeDef.getName(), is("my-type"));
-//
-// leafIterator = grouping.getListOfLeaf().listIterator();
-// leafInfo = leafIterator.next();
-//
-// // Check whether the information in the leaf is correct under grouping.
-// assertThat(leafInfo.getName(), is("zip-code"));
-// assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
-// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
-//
-// // Check whether uses is endpoint-grouping's sibling.
-// assertThat((grouping.getNextSibling() instanceof YangUses), is(true));
-// YangUses endpointUses = (YangUses) grouping.getNextSibling();
-//
-// // Check whether uses get resolved.
-// assertThat(endpointUses.getResolvableStatus(),
-// is(ResolvableStatus.RESOLVED));
-//
-// assertThat((endpointUses.getNextSibling().getNextSibling().getNextSibling().getNextSibling().getNextSibling()
-// .getNextSibling() instanceof YangUses), is(true));
-//
-// YangUses yangUsesInEndpoint = (YangUses) endpointUses.getNextSibling().getNextSibling().getNextSibling()
-// .getNextSibling().getNextSibling().getNextSibling();
-// assertThat(yangUsesInEndpoint.getResolvableStatus(),
-// is(ResolvableStatus.RESOLVED));
-//
-// assertThat((yangUsesInEndpoint.getNextSibling() instanceof YangContainer), is(true));
-// YangContainer yangContainerInEndPoint = (YangContainer) yangUsesInEndpoint.getNextSibling();
-//
-// assertThat(yangContainerInEndPoint.getName(), is("design"));
+ ListIterator<YangNode> thirdUsesChildren = thirdUses.getUsesResolvedNodeList().listIterator();
+ YangNode thirdUsesChild = thirdUsesChildren.next();
+
+ // Check whether container is the child of uses.
+ assertThat((thirdUsesChild instanceof YangContainer), is(true));
+
+ YangContainer yangContainer3 = (YangContainer) thirdUsesChild;
+ assertThat(yangContainer3.getName(), is("value"));
+
+ leafIterator = yangContainer3.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under container
+ // which has been deep copied from grouping.
+ assertThat(leafInfo.getName(), is("zip-code"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+
+
+ // Check whether uses is the sibling of container-design.
+ assertThat((yangContainer.getNextSibling() instanceof YangUses), is(true));
+ YangUses fourthUses = (YangUses) yangContainer.getNextSibling();
+ assertThat(fourthUses.getName(), is("fourth"));
+ // Check whether uses get resolved.
+ assertThat(fourthUses.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ ListIterator<List<YangLeaf>> fourthUsesChildren = fourthUses.getUsesResolvedLeavesList().listIterator();
+ List<YangLeaf> fourthUsesChild = fourthUsesChildren.next();
+ ListIterator<YangLeaf> fourthUsesChildren1 = fourthUsesChild.listIterator();
+ YangLeaf fourthUsesChild1 = fourthUsesChildren1.next();
+
+ // Check whether the information in the leaf is correct under correct-container.
+ assertThat(fourthUsesChild1.getName(), is("correct"));
+ assertThat(fourthUsesChild1.getDataType().getDataTypeName(), is("my-type"));
+ assertThat(fourthUsesChild1.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+
+ // Check whether uses is the sibling of previous uses.
+ assertThat((fourthUses.getNextSibling() instanceof YangUses), is(true));
+ YangUses fifthUses = (YangUses) fourthUses.getNextSibling();
+ assertThat(fifthUses.getName(), is("fifth"));
+
+ // Check whether uses get resolved.
+ assertThat(fifthUses.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ ListIterator<List<YangLeaf>> fifthUsesChildren = fifthUses.getUsesResolvedLeavesList().listIterator();
+ List<YangLeaf> fifthUsesChild = fifthUsesChildren.next();
+ ListIterator<YangLeaf> fifthUsesChildren1 = fifthUsesChild.listIterator();
+ YangLeaf fifthUsesChild1 = fifthUsesChildren1.next();
+
+ //Check whether the information in the leaf is correct under correct-container.
+ assertThat(fifthUsesChild1.getName(), is("abc"));
+ assertThat(fifthUsesChild1.getDataType().getDataTypeName(), is("string"));
+ assertThat(fifthUsesChild1.getDataType().getDataType(), is(YangDataTypes.STRING));
+
+ //Check whether uses is endpoint-grouping's sibling.
+ assertThat((grouping.getNextSibling() instanceof YangUses), is(true));
+ YangUses endpointUses = (YangUses) grouping.getNextSibling();
+
+ // Check whether uses get resolved.
+ assertThat(endpointUses.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+ assertThat(endpointUses.getName(), is("endpoint"));
+
+ ListIterator<YangNode> endpointUsesUsesChildren = endpointUses.getUsesResolvedNodeList().listIterator();
+ YangNode endpointUsesUsesChild = endpointUsesUsesChildren.next();
+
+ // Check whether list is the sibling of uses.
+ assertThat((endpointUsesUsesChild instanceof YangList), is(true));
+ YangList yangList1 = (YangList) firstUsesChild;
+ assertThat(yangList1.getName(), is("valid"));
+
+ leafIterator = yangList1.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under list which has been deep copied from grouping.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
}
/**
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataTypeTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataTypeTest.java
index f2ca36e..35cc4bc 100644
--- a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataTypeTest.java
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataTypeTest.java
@@ -26,8 +26,10 @@
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDef;
+import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
@@ -37,9 +39,9 @@
import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32;
import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT8;
-import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaDataType;
-import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaImportClass;
-import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaImportPackage;
+import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.getJavaDataType;
+import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.getJavaImportClass;
+import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.getJavaImportPackage;
import static org.onosproject.yangutils.utils.UtilConstants.JAVA_LANG;
/**
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/ChoiceCaseTranslatorTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/ChoiceCaseTranslatorTest.java
index 74043f6..993d38c 100644
--- a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/ChoiceCaseTranslatorTest.java
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/ChoiceCaseTranslatorTest.java
@@ -22,6 +22,7 @@
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/EnumTranslatorTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/EnumTranslatorTest.java
index 2a950fc..742d310 100644
--- a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/EnumTranslatorTest.java
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/EnumTranslatorTest.java
@@ -22,6 +22,7 @@
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntaxTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntaxTest.java
index 6b86b9c..b844b27 100644
--- a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntaxTest.java
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntaxTest.java
@@ -23,16 +23,17 @@
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onosproject.yangutils.translator.exception.TranslatorException;
+import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertThat;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getJavaPackageFromPackagePath;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getJavaPackageFromPackagePath;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase;
import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT_BASE_PKG;
import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java
index 05fe52d..aee10f7 100644
--- a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java
@@ -23,13 +23,14 @@
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo;
import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertThat;
import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuild;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildForInterface;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getCheckNotNull;
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/NotificationTranslatorTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/NotificationTranslatorTest.java
index f4d8bf8..e45b1d8 100644
--- a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/NotificationTranslatorTest.java
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/NotificationTranslatorTest.java
@@ -22,6 +22,7 @@
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/RpcTranslatorTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/RpcTranslatorTest.java
index 9b8077c..04ef477 100644
--- a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/RpcTranslatorTest.java
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/RpcTranslatorTest.java
@@ -22,6 +22,7 @@
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/UnionTranslatorTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/UnionTranslatorTest.java
index 9dcdfdf..0441c87 100644
--- a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/UnionTranslatorTest.java
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/UnionTranslatorTest.java
@@ -22,6 +22,7 @@
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtilTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtilTest.java
index 5fd728b..05ffa81 100644
--- a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtilTest.java
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtilTest.java
@@ -25,7 +25,6 @@
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.hamcrest.core.Is.is;
@@ -34,8 +33,8 @@
import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.appendFileContents;
-import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage;
-import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.doesPackageExist;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.doesPackageExist;
import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileHandle;
/**
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/JavaDocGenTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/JavaDocGenTest.java
index 2e9f436..5b36403 100644
--- a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/JavaDocGenTest.java
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/JavaDocGenTest.java
@@ -22,7 +22,6 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
@@ -207,4 +206,4 @@
pluginConfig.setConflictResolver(null);
return pluginConfig;
}
-}
\ No newline at end of file
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/YangIoUtilsTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/YangIoUtilsTest.java
index c10ed03..38d18c2 100644
--- a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/YangIoUtilsTest.java
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/YangIoUtilsTest.java
@@ -26,17 +26,15 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
import org.onosproject.yangutils.utils.UtilConstants;
import org.sonatype.plexus.build.incremental.BuildContext;
import org.sonatype.plexus.build.incremental.DefaultBuildContext;
-import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertThat;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.addPackageInfo;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.addToCompilationRoot;
+import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.addToCompilationRoot;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.createDirectories;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast;