Whitebox issue fix

Change-Id: I856266e26d2686affb9271c460927ba3e0e07db2
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/ResolvableStatus.java b/src/main/java/org/onosproject/yangutils/datamodel/ResolvableStatus.java
index 2514441..d1cacb4 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/ResolvableStatus.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/ResolvableStatus.java
@@ -40,6 +40,6 @@
     /**
      * Identifies that resolvable entity is resolved.
      */
-    RESOLVED;
+    RESOLVED
 
 }
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangLeavesHolder.java b/src/main/java/org/onosproject/yangutils/datamodel/YangLeavesHolder.java
index fd22a99..37ecc8f 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangLeavesHolder.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangLeavesHolder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Open Networking Laboratory
+ * 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.
@@ -28,28 +28,28 @@
     /**
      * Returns the list of leaves from data holder like container / list.
      *
-     * @return the list of leaves.
+     * @return the list of leaves
      */
-    public List<YangLeaf> getListOfLeaf();
+    List<YangLeaf> getListOfLeaf();
 
     /**
-     * Add a leaf in data holder like container / list.
+     * Adds leaf in data holder like container / list.
      *
-     * @param leaf the leaf to be added.
+     * @param leaf the leaf to be added
      */
     void addLeaf(YangLeaf leaf);
 
     /**
      * Returns the list of leaf-list from data holder like container / list.
      *
-     * @return the list of leaf-list.
+     * @return the list of leaf-list
      */
     List<YangLeafList> getListOfLeafList();
 
     /**
-     * Add a leaf-list in data holder like container / list.
+     * Adds leaf-list in data holder like container / list.
      *
-     * @param leafList the leaf-list to be added.
+     * @param leafList the leaf-list to be added
      */
     void addLeafList(YangLeafList leafList);
 }
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/utils/GeneratedLanguage.java b/src/main/java/org/onosproject/yangutils/datamodel/utils/GeneratedLanguage.java
index e2471cd..37d2161 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/utils/GeneratedLanguage.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/utils/GeneratedLanguage.java
@@ -20,7 +20,7 @@
  */
 public enum GeneratedLanguage {
     /**
-     * Java.
+     * Target language is java.
      */
-    JAVA_GENERATION;
+    JAVA_GENERATION
 }
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/YangUtilsParserManager.java b/src/main/java/org/onosproject/yangutils/parser/impl/YangUtilsParserManager.java
index a1fffb8..6a5b1d2 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/YangUtilsParserManager.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/YangUtilsParserManager.java
@@ -43,12 +43,11 @@
          * Create a char stream that reads from YANG file. Throws an exception
          * in case input YANG file is either null or non existent.
          */
-        ANTLRInputStream input = null;
+        ANTLRInputStream input;
         try {
             input = new ANTLRFileStream(yangFile);
         } catch (IOException e) {
-            e.printStackTrace();
-            throw e;
+            throw new ParserException("YANG file error : YANG file does not exist.");
         }
 
         // Create a lexer that feeds off of input char stream.
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/StatusListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/StatusListener.java
index b91003b..4c2abf9 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/StatusListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/StatusListener.java
@@ -22,10 +22,10 @@
 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
+import org.onosproject.yangutils.utils.YangConstructType;
 
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CONTENT;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat;
@@ -44,7 +44,7 @@
  *                        deprecated-keyword
  *
  * ANTLR grammar rule
- * statusStatement : STATUS_KEYWORD (CURRENT_KEYWORD | OBSOLETE_KEYWORD | DEPRECATED_KEYWORD) STMTEND;
+ * statusStatement : STATUS_KEYWORD status STMTEND;
  */
 
 /**
@@ -99,14 +99,27 @@
         YangStatusType status;
 
         String value = removeQuotesAndHandleConcat(ctx.status().getText());
-        if (value.equals(CURRENT_KEYWORD)) {
-            status = YangStatusType.CURRENT;
-        } else if (value.equals(DEPRECATED_KEYWORD)) {
-            status = YangStatusType.DEPRECATED;
-        } else if (value.equals(OBSOLETE_KEYWORD)) {
-            status = YangStatusType.OBSOLETE;
-        } else {
-            throw new ParserException(constructListenerErrorMessage(INVALID_CONTENT, STATUS_DATA, value, ENTRY));
+        switch (value) {
+            case CURRENT_KEYWORD: {
+                status = YangStatusType.CURRENT;
+                break;
+            }
+            case DEPRECATED_KEYWORD: {
+                status = YangStatusType.DEPRECATED;
+                break;
+            }
+            case OBSOLETE_KEYWORD: {
+                status = YangStatusType.OBSOLETE;
+                break;
+            }
+            default: {
+                ParserException parserException = new ParserException("YANG file error : " +
+                        YangConstructType.getYangConstructType(STATUS_DATA) + " " + ctx.status().getText() +
+                        " is not valid.");
+                parserException.setLine(ctx.getStart().getLine());
+                parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
+                throw parserException;
+            }
         }
 
         return status;
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/HasJavaFileInfo.java b/src/main/java/org/onosproject/yangutils/translator/tojava/HasJavaFileInfo.java
index c73258e..efd4be8 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/HasJavaFileInfo.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/HasJavaFileInfo.java
@@ -26,12 +26,12 @@
      *
      * @return generated java file information
      */
-    public JavaFileInfo getJavaFileInfo();
+    JavaFileInfo getJavaFileInfo();
 
     /**
      * Sets the java file info object.
      *
      * @param javaInfo java file info object
      */
-    public void setJavaFileInfo(JavaFileInfo javaInfo);
+    void setJavaFileInfo(JavaFileInfo javaInfo);
 }
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/HasJavaImportData.java b/src/main/java/org/onosproject/yangutils/translator/tojava/HasJavaImportData.java
index 4ae28dd..7251b7f 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/HasJavaImportData.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/HasJavaImportData.java
@@ -25,7 +25,7 @@
      *
      * @return data of java imports to be included in generated file
      */
-    public JavaImportData getJavaImportData();
+    JavaImportData getJavaImportData();
 
     /**
      * Sets the data of java imports to be included in generated file.
@@ -33,5 +33,5 @@
      * @param javaImportData data of java imports to be included in generated
      *            file
      */
-    public void setJavaImportData(JavaImportData javaImportData);
+    void setJavaImportData(JavaImportData javaImportData);
 }
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGeneratorUtil.java b/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGeneratorUtil.java
index 577a3ba..7e010db 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGeneratorUtil.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGeneratorUtil.java
@@ -29,7 +29,7 @@
 import static org.onosproject.yangutils.translator.tojava.TraversalType.SIBILING;
 
 /**
- * Representation of Java code generator based on application schema.
+ * Representation of java code generator based on application schema.
  */
 public final class JavaCodeGeneratorUtil {
 
@@ -75,7 +75,7 @@
         YangNode curNode = rootNode;
         TraversalType curTraversal = ROOT;
 
-        while (!(curNode == null)) {
+        while (curNode != null) {
             if (curTraversal != PARENT) {
                 setCurNode(curNode);
                 generateCodeEntry(curNode, yangPlugin);
@@ -166,9 +166,8 @@
      * Free the current node.
      *
      * @param node YANG node
-     * @throws DataModelException when fails to do datamodel operations
      */
-    private static void free(YangNode node) throws DataModelException {
+    private static void free(YangNode node) {
 
         YangNode parent = node.getParent();
         parent.setChild(null);
@@ -202,7 +201,7 @@
         setCurNode(curNode.getChild());
         TraversalType curTraversal = ROOT;
 
-        while (!(curNode == null)) {
+        while (curNode != null) {
 
             if (curTraversal != PARENT) {
                 close(curNode);
@@ -220,7 +219,6 @@
         }
 
         freeRestResources();
-        curNode = null;
     }
 
     /**
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/JavaImportData.java b/src/main/java/org/onosproject/yangutils/translator/tojava/JavaImportData.java
index 469e416..2c2ce05 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/JavaImportData.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/JavaImportData.java
@@ -19,6 +19,7 @@
 import java.util.List;
 import java.util.SortedSet;
 import java.util.TreeSet;
+import static java.util.Collections.sort;
 
 import org.onosproject.yangutils.datamodel.YangNode;
 import org.onosproject.yangutils.translator.exception.TranslatorException;
@@ -62,7 +63,7 @@
     /**
      * Returns if the list needs to be imported.
      *
-     * @return true if any of the attribute needs to be maintained as a list.
+     * @return true if any of the attribute needs to be maintained as a list
      */
     public boolean getIfListImported() {
         return isListToImport;
@@ -71,7 +72,7 @@
     /**
      * Sets the status of importing list.
      *
-     * @param isList status to mention list is bing imported.
+     * @param isList status to mention list is bing imported
      */
     public void setIfListImported(boolean isList) {
         isListToImport = isList;
@@ -138,10 +139,9 @@
         List<String> imports = new ArrayList<>();
 
         for (JavaQualifiedTypeInfo importInfo : getImportSet()) {
-            importString = IMPORT;
-            if (importInfo.getPkgInfo() != EMPTY_STRING && importInfo.getClassInfo() != null
-                    && importInfo.getPkgInfo() != JAVA_LANG) {
-                importString = importString + importInfo.getPkgInfo() + PERIOD + importInfo.getClassInfo() + SEMI_COLAN
+            if (!importInfo.getPkgInfo().equals(EMPTY_STRING) && importInfo.getClassInfo() != null
+                    && !importInfo.getPkgInfo().equals(JAVA_LANG)) {
+                importString = IMPORT + importInfo.getPkgInfo() + PERIOD + importInfo.getClassInfo() + SEMI_COLAN
                         + NEW_LINE;
 
                 imports.add(importString);
@@ -152,7 +152,7 @@
             imports.add(getImportForList());
         }
 
-        java.util.Collections.sort(imports);
+        sort(imports);
         return imports;
     }
 
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaCodeFragmentFiles.java b/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaCodeFragmentFiles.java
index c815c95..205990f 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaCodeFragmentFiles.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaCodeFragmentFiles.java
@@ -1108,7 +1108,6 @@
                 addToStringMethod(newAttrInfo);
             }
         }
-        return;
     }
 
     /**
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java
index d6ba066..8895da2 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java
@@ -136,9 +136,11 @@
         YangJavaModelUtils.generateCodeOfRootNode(this, yangPlugin, modulePkg);
     }
 
+    /**
+     * Creates a java file using the YANG module info.
+     */
     @Override
     public void generateCodeExit() throws IOException {
         getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
-        return;
     }
 }
diff --git a/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java b/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java
index 3765f71..ffc36f7 100644
--- a/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java
+++ b/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java
@@ -53,7 +53,6 @@
      * @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");
         if (pkgDir.exists() && pkgWithFile.isFile()) {
@@ -70,7 +69,6 @@
      * @throws IOException any IO exception
      */
     public static void createPackage(String pkg, String pkgInfo) throws IOException {
-
         if (!doesPackageExist(pkg)) {
             try {
                 File pack = createDirectories(pkg);
@@ -92,9 +90,7 @@
      * @throws IOException any IO errors
      */
     public static void appendFileContents(File toAppend, File srcFile) throws IOException {
-
         updateFileHandle(srcFile, NEW_LINE + readAppendFile(toAppend.toString(), FOUR_SPACE_INDENTATION), false);
-        return;
     }
 
     /**
@@ -106,7 +102,6 @@
      * @throws IOException when fails to convert to string
      */
     public static String readAppendFile(String toAppend, String spaces) throws IOException {
-
         FileReader fileReader = new FileReader(toAppend);
         BufferedReader bufferReader = new BufferedReader(fileReader);
         try {
@@ -114,8 +109,8 @@
             String line = bufferReader.readLine();
 
             while (line != null) {
-                if (line.equals(SPACE) | line.equals(EMPTY_STRING) | line.equals(EIGHT_SPACE_INDENTATION)
-                        | line.equals(MULTIPLE_NEW_LINE)) {
+                if (line.equals(SPACE) || line.equals(EMPTY_STRING) || line.equals(EIGHT_SPACE_INDENTATION)
+                        || line.equals(MULTIPLE_NEW_LINE)) {
                     stringBuilder.append(NEW_LINE);
                 } else if (line.equals(FOUR_SPACE_INDENTATION)) {
                     stringBuilder.append(EMPTY_STRING);
@@ -142,7 +137,6 @@
      * does not exist but cannot be created, or cannot be opened for any other reason
      */
     public static void updateFileHandle(File inputFile, String contentTobeAdded, boolean isClose) throws IOException {
-
         FileWriter fileWriter = new FileWriter(inputFile, true);
         PrintWriter outputPrintWriter = new PrintWriter(fileWriter, true);
         if (!isClose) {
diff --git a/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java b/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
index 982cbc4..c76ecad 100644
--- a/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
+++ b/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
@@ -17,7 +17,6 @@
 package org.onosproject.yangutils.utils.io.impl;
 
 import org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax;
-import org.onosproject.yangutils.utils.UtilConstants;
 
 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_CLASS_JAVA_DOC;
@@ -62,7 +61,7 @@
     /**
      * JavaDocs types.
      */
-    public static enum JavaDocType {
+    public enum JavaDocType {
 
         /**
          * For class.
@@ -141,7 +140,7 @@
     public static String getJavaDoc(JavaDocType type, String name, boolean isList) {
 
         name = JavaIdentifierSyntax.getSmallCase(JavaIdentifierSyntax.getCamelCase(name, null));
-        String javaDoc = UtilConstants.EMPTY_STRING;
+        String javaDoc;
         if (type.equals(JavaDocType.IMPL_CLASS)) {
             javaDoc = generateForImplClass(name);
         } else if (type.equals(JavaDocType.BUILDER_CLASS)) {
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/YangUtilsParserManagerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/YangUtilsParserManagerTest.java
index 6924849..9b3effc 100644
--- a/src/test/java/org/onosproject/yangutils/parser/impl/YangUtilsParserManagerTest.java
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/YangUtilsParserManagerTest.java
@@ -60,7 +60,7 @@
      * This test case checks whether the io exception is generated
      * when the input YANG file is non existent.
      */
-    @Test(expected = IOException.class)
+    @Test(expected = ParserException.class)
     public void getDataModelNonExistentFileTest() throws IOException, ParserException {
 
         YangUtilsParserManager manager = new YangUtilsParserManager();
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/StatusListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/StatusListenerTest.java
index d4fc841..8e44429 100644
--- a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/StatusListenerTest.java
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/StatusListenerTest.java
@@ -140,7 +140,7 @@
     @Test
     public void processStatusInvalidValue() throws IOException, ParserException {
         thrown.expect(ParserException.class);
-        thrown.expectMessage("Invalid content in status \"invalid\" before processing.");
+        thrown.expectMessage("YANG file error : status invalid is not valid.");
         YangNode node = manager.getDataModel("src/test/resources/StatusInvalidValue.yang");
     }