Sonar issues clean-up 15/18615/2
authorMartin Ciglan <mciglan@cisco.com>
Mon, 20 Apr 2015 12:13:23 +0000 (14:13 +0200)
committerMartin Ciglan <mciglan@cisco.com>
Mon, 20 Apr 2015 12:15:27 +0000 (12:15 +0000)
Change-Id: Ic1b3a836efc17f6f589238be26ece2bd08ebcc0a
Signed-off-by: Martin Ciglan <mciglan@cisco.com>
15 files changed:
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/YangStatementParserListenerImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/AugmentStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/AugmentUtils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ContainerStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/GroupingStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/GroupingUtils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ImportStatementDefinition.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/IncludeStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/InputStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ModuleStatementSupport.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/OutputStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/SubmoduleStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/UsesStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/Utils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YangStatementSourceImpl.java

index cfc3546472b0e5e54ee4b27051c070407e3450ad..6a0d38e2441384cd049bb8c4fe69855c8213879b 100644 (file)
@@ -9,6 +9,8 @@ package org.opendaylight.yangtools.yang.parser.impl;
 
 import java.util.ArrayList;
 import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.antlr.v4.runtime.tree.ParseTree;
 import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser;
@@ -29,6 +31,7 @@ public class YangStatementParserListenerImpl extends YangStatementParserBaseList
     private QNameToStatementDefinition stmtDef;
     private PrefixToModule prefixes;
     private List<String> toBeSkipped = new ArrayList<>();
+    private static final Logger LOG = LoggerFactory.getLogger(YangStatementParserListenerImpl.class);
 
     public YangStatementParserListenerImpl(StatementSourceReference ref) {
         this.ref = ref;
@@ -61,7 +64,7 @@ public class YangStatementParserListenerImpl extends YangStatementParserBaseList
                         toBeSkipped.add(((YangStatementParser.KeywordContext) child).children.get(0).getText());
                     }
                 } catch (SourceException e) {
-                    e.printStackTrace();
+                    LOG.warn(e.getMessage(), e);
                 }
             } else if (child instanceof YangStatementParser.ArgumentContext) {
                 try {
@@ -71,7 +74,7 @@ public class YangStatementParserListenerImpl extends YangStatementParserBaseList
                     else
                         action = true;
                 } catch (SourceException e) {
-                    e.printStackTrace();
+                    LOG.warn(e.getMessage(), e);
                 }
             }
 
@@ -94,7 +97,7 @@ public class YangStatementParserListenerImpl extends YangStatementParserBaseList
                         toBeSkipped.remove(statementName);
                     }
                 } catch (SourceException e) {
-                    e.printStackTrace();
+                    LOG.warn(e.getMessage(), e);
                 }
             }
         }
index 8eabcb68ebf0e11ff7e255b3b99ed3c8c4b1780a..54dd02353de6eef7e5ca57ee4dede45965284a56 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 import static org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase.EFFECTIVE_MODEL;
 
 import java.util.Collection;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import javax.annotation.Nonnull;
 
 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
@@ -30,13 +31,13 @@ import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AugmentEffe
 
 public class AugmentStatementImpl extends AbstractDeclaredStatement<SchemaNodeIdentifier> implements AugmentStatement {
 
+    private static final Logger LOG = LoggerFactory.getLogger(AugmentStatementImpl.class);
+
     protected AugmentStatementImpl(StmtContext<SchemaNodeIdentifier, AugmentStatement, ?> context) {
         super(context);
     }
 
-    public static class Definition
-            extends
-            AbstractStatementSupport<SchemaNodeIdentifier, AugmentStatement, EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>> {
+    public static class Definition extends AbstractStatementSupport<SchemaNodeIdentifier, AugmentStatement, EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>> {
 
         public Definition() {
             super(Rfc6020Mapping.AUGMENT);
@@ -72,15 +73,13 @@ public class AugmentStatementImpl extends AbstractDeclaredStatement<SchemaNodeId
                 @Override
                 public void apply() throws InferenceException {
 
-                    final StatementContextBase<?, ?, ?> augmentTargetCtx = AugmentUtils
-                            .getAugmentTargetCtx(augmentNode);
-                    StatementContextBase<?, ?, ?> augmentSourceCtx = (StatementContextBase<?, ?, ?>) sourceCtxPrereq
-                            .get();
+                    final StatementContextBase<?, ?, ?> augmentTargetCtx = AugmentUtils.getAugmentTargetCtx(augmentNode);
+                    final StatementContextBase<?, ?, ?> augmentSourceCtx = (StatementContextBase<?, ?, ?>) sourceCtxPrereq.get();
 
                     try {
                         AugmentUtils.copyFromSourceToTarget(augmentSourceCtx, augmentTargetCtx);
                     } catch (SourceException e) {
-                        e.printStackTrace();
+                        LOG.warn(e.getMessage(), e);
                     }
                 }
 
index 66cfd1d51ed332f91a9446f4c67e415195d55bfa..3b9c18c0333b2a441a8b2e1cb21acf46e0888a01 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.Set;
 
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
@@ -24,7 +25,10 @@ import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
 
-public class AugmentUtils {
+public final class AugmentUtils {
+
+    private AugmentUtils() {
+    }
 
     private static final String REGEX_PATH_REL1 = "\\.\\.?\\s*/(.+)";
     private static final String REGEX_PATH_REL2 = "//.*";
@@ -86,24 +90,23 @@ public class AugmentUtils {
             QName targetQName = (QName) targetStmtArgument;
             QNameModule targetQNameModule = targetQName.getModule();
 
-            if (targetQNameModule.equals(sourceQNameModule))
+            if (targetQNameModule.equals(sourceQNameModule)) {
                 return null;
-            else
+            } else {
                 return targetQNameModule;
-        } else
+            }
+        } else {
             return null;
+        }
     }
 
     public static boolean needToCopyByAugment(StmtContext<?, ?, ?> stmtContext) {
 
-        HashSet<StatementDefinition> noCopyDefSet = new HashSet<>();
+        Set<StatementDefinition> noCopyDefSet = new HashSet<>();
         noCopyDefSet.add(Rfc6020Mapping.USES);
 
         StatementDefinition def = stmtContext.getPublicDefinition();
-        if (noCopyDefSet.contains(def))
-            return false;
-        else
-            return true;
+        return (!noCopyDefSet.contains(def));
     }
 
     public static boolean isReusedByAugment(StmtContext<?, ?, ?> stmtContext) {
index 69f839bb96db9464a592e0f9a5d933d1e7757ea4..f940f026d3322c75eab8e3899257be4e2b4903aa 100644 (file)
@@ -30,11 +30,9 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
 public class ContainerStatementImpl extends AbstractDeclaredStatement<QName> implements ContainerStatement {
-    //private QName qname;
 
     protected ContainerStatementImpl(StmtContext<QName, ContainerStatement,?> context) {
         super(context);
-        //this.qname =
     }
 
     public static class Definition extends AbstractStatementSupport<QName,ContainerStatement,EffectiveStatement<QName,ContainerStatement>> {
index 06ebd38929341673a16675c3d224205b40b67e91..4f2a7ce735e2f3b6db6649d5f23005a0a09acf82 100644 (file)
@@ -62,10 +62,8 @@ public class GroupingStatementImpl extends AbstractDeclaredStatement<QName>
 
         @Override
         public void onFullDefinitionDeclared(
-                Mutable<QName, GroupingStatement, EffectiveStatement<QName, GroupingStatement>> stmt)
-                throws InferenceException, SourceException {
+                Mutable<QName, GroupingStatement, EffectiveStatement<QName, GroupingStatement>> stmt) throws SourceException {
             stmt.getParentContext().addContext(GroupingNamespace.class, stmt.getStatementArgument(),stmt);
-            //
         }
 
     }
index 44f91489ab9045b41b0a2d560e135e7d2a6ed99e..f5a996dbe099fb2156004a0108534824ac31b4a8 100644 (file)
@@ -9,6 +9,8 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.Set;
+
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
@@ -24,7 +26,10 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
 
-public class GroupingUtils {
+public final class GroupingUtils {
+
+    private GroupingUtils() {
+    }
 
     /**
      * @param sourceGrpStmtCtx
@@ -90,14 +95,18 @@ public class GroupingUtils {
                 QName sourceQName = (QName) sourceStmtArgument;
                 QNameModule sourceQNameModule = sourceQName.getModule();
 
-                if (targetQNameModule.equals(sourceQNameModule))
+                if (targetQNameModule.equals(sourceQNameModule)) {
                     return null;
-                else
+                }
+                else {
                     return targetQNameModule;
-            } else
+                }
+            } else {
                 return null;
-        } else
+            }
+        } else {
             return null;
+        }
     }
 
     public static boolean needToCreateNewQName(
@@ -107,26 +116,20 @@ public class GroupingUtils {
 
     public static boolean needToCopyByUses(StmtContext<?, ?, ?> stmtContext) {
 
-        HashSet<StatementDefinition> noCopyDefSet = new HashSet<StatementDefinition>();
+        Set<StatementDefinition> noCopyDefSet = new HashSet<StatementDefinition>();
         noCopyDefSet.add(Rfc6020Mapping.USES);
 
         StatementDefinition def = stmtContext.getPublicDefinition();
-        if (noCopyDefSet.contains(def))
-            return false;
-        else
-            return true;
+        return (!noCopyDefSet.contains(def));
     }
 
     public static boolean isReusedByUses(StmtContext<?, ?, ?> stmtContext) {
 
-        HashSet<StatementDefinition> reusedDefSet = new HashSet<StatementDefinition>();
+        Set<StatementDefinition> reusedDefSet = new HashSet<StatementDefinition>();
         reusedDefSet.add(Rfc6020Mapping.TYPEDEF);
 
         StatementDefinition def = stmtContext.getPublicDefinition();
-        if (reusedDefSet.contains(def))
-            return true;
-        else
-            return false;
+        return (reusedDefSet.contains(def));
     }
 
     public static void resolveUsesNode(
index 01451c92d4c7335639eb71227770f7665cec3fa2..6863486d68914fe7473c25552ff5d4884043e58a 100644 (file)
@@ -62,7 +62,7 @@ public class ImportStatementDefinition extends
     @Override
     public void onLinkageDeclared(
             final Mutable<String, ImportStatement, EffectiveStatement<String, ImportStatement>> stmt)
-            throws InferenceException, SourceException {
+            throws SourceException {
         final ModuleIdentifier impIdentifier = getImportedModuleIdentifier(stmt);
         ModelActionBuilder importAction = stmt.newInferenceAction(SOURCE_LINKAGE);
         final Prerequisite<StmtContext<?, ?, ?>> imported;
@@ -78,13 +78,7 @@ public class ImportStatementDefinition extends
             @Override
             public void apply() throws InferenceException {
                 StmtContext<?, ?, ?> importedModule = imported.get();
-                // URI importedNs =
-                // importedModule.firstSubstatement(NamespaceStatement.class).argument();
-                // String prefix =
-                // stmt.firstSubstatement(PrefixStatement.class).argument();
                 linkageTarget.get().addToNs(ImportedModuleContext.class, impIdentifier, importedModule);
-                // prefixTarget.get().addToNs(PrefixToModule.class, prefix,
-                // QNameModule.create(importedNs, null));
             }
 
             @Override
index 4b425c33e161b5c5653e9d53280ac4024bbc8adc..70effef3906ca37ae4656323a829ad26a2cbd699 100644 (file)
@@ -68,7 +68,7 @@ public class IncludeStatementImpl extends AbstractDeclaredStatement<String> impl
         @Override
         public void onLinkageDeclared(
                 final Mutable<String, IncludeStatement, EffectiveStatement<String, IncludeStatement>> stmt)
-                throws InferenceException, SourceException {
+                throws SourceException {
             final ModuleIdentifier includeSubmoduleIdentifier = getIncludeSubmoduleIdentifier(stmt);
 
             ModelActionBuilder includeAction = stmt.newInferenceAction(SOURCE_LINKAGE);
@@ -89,7 +89,6 @@ public class IncludeStatementImpl extends AbstractDeclaredStatement<String> impl
 
                 @Override
                 public void prerequisiteFailed(Collection<? extends Prerequisite<?>> failed) throws InferenceException {
-                    System.out.println("");
                     if (failed.contains(requiresCtxPrerequisite)) {
                         throw new InferenceException("Included submodule was not found.", stmt
                                 .getStatementSourceReference());
index e0b7189a3fc1c0c6d9a535063b1bf4f6155af321..8f970c0c24582b99d7929300127eb48088ea3f2e 100644 (file)
@@ -40,8 +40,7 @@ public class InputStatementImpl extends AbstractDeclaredStatement<QName>
         @Override
         public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
                 throws SourceException {
-            value = "input";
-            return Utils.qNameFromArgument(ctx, value);
+            return Utils.qNameFromArgument(ctx, "input");
         }
 
         @Override
index 3324b876e2c09bd5c810f71d23f0780f531002e7..e2c6b531db1e8eae0f93b09d5327f92f82466c0d 100644 (file)
@@ -63,7 +63,7 @@ public class ModuleStatementSupport extends
 
     @Override
     public void onLinkageDeclared(Mutable<String, ModuleStatement, EffectiveStatement<String, ModuleStatement>> stmt)
-            throws InferenceException, SourceException {
+            throws SourceException {
 
         Optional<URI> moduleNs = Optional.fromNullable(firstAttributeOf(stmt.declaredSubstatements(),
                 NamespaceStatement.class));
index f362fbf4abaf1044f5461909d06bb6b8983396a3..86734f720852b242d1cd30281dc2527385cb5811 100644 (file)
@@ -41,8 +41,7 @@ public class OutputStatementImpl extends AbstractDeclaredStatement<QName>
         @Override
         public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
                 throws SourceException {
-            value = "output";
-            return Utils.qNameFromArgument(ctx, value);
+            return Utils.qNameFromArgument(ctx, "output");
         }
 
         @Override
index 66f1c712a546f007b878ca4ee76201deb822bd3a..7349082ec503e8610f5e2bb226838306bba575c2 100644 (file)
@@ -67,7 +67,7 @@ public class SubmoduleStatementImpl extends
         @Override
         public void onLinkageDeclared(
                 Mutable<String, SubmoduleStatement, EffectiveStatement<String, SubmoduleStatement>> stmt)
-                throws InferenceException, SourceException {
+                throws SourceException {
 
             Optional<Date> revisionDate = Optional
                     .fromNullable(firstAttributeOf(
index 631fb31795418774dc8158ac15e6314d408cce03..326e92a8073dc7215ff8e58fb5a192a95765ac5c 100644 (file)
@@ -10,6 +10,8 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 import static org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase.FULL_DECLARATION;
 
 import java.util.Collection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
@@ -37,8 +39,11 @@ import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.UsesEffectiveStatementImpl;
 
+
 public class UsesStatementImpl extends AbstractDeclaredStatement<QName> implements UsesStatement {
 
+    private static final Logger LOG = LoggerFactory.getLogger(UsesStatementImpl.class);
+
     protected UsesStatementImpl(StmtContext<QName, UsesStatement, ?> context) {
         super(context);
     }
@@ -58,7 +63,7 @@ public class UsesStatementImpl extends AbstractDeclaredStatement<QName> implemen
         @Override
         public void onFullDefinitionDeclared(
                 final StmtContext.Mutable<QName, UsesStatement, EffectiveStatement<QName, UsesStatement>> usesNode)
-                throws InferenceException, SourceException {
+                throws SourceException {
 
             ModelActionBuilder usesAction = usesNode.newInferenceAction(FULL_DECLARATION);
             final QName groupingName = usesNode.getStatementArgument();
@@ -72,31 +77,25 @@ public class UsesStatementImpl extends AbstractDeclaredStatement<QName> implemen
 
                 @Override
                 public void apply() throws InferenceException {
-                    StatementContextBase<?, ?, ?> targetNodeStmtCtx = (StatementContextBase<?, ?, ?>) targetNodePre
-                            .get();
-                    StatementContextBase<?, ?, ?> sourceGrpStmtCtx = (StatementContextBase<?, ?, ?>) sourceGroupingPre
-                            .get();
+                    StatementContextBase<?, ?, ?> targetNodeStmtCtx = (StatementContextBase<?, ?, ?>) targetNodePre.get();
+                    StatementContextBase<?, ?, ?> sourceGrpStmtCtx = (StatementContextBase<?, ?, ?>) sourceGroupingPre.get();
 
                     try {
                         GroupingUtils.copyFromSourceToTarget(sourceGrpStmtCtx, targetNodeStmtCtx);
                         GroupingUtils.resolveUsesNode(usesNode, targetNodeStmtCtx);
                     } catch (SourceException e) {
-                        // TODO Auto-generated catch block
-                        e.printStackTrace();
+                        LOG.warn(e.getMessage(), e);
                     }
                 }
 
                 @Override
                 public void prerequisiteFailed(Collection<? extends Prerequisite<?>> failed) throws InferenceException {
                     if (failed.contains(sourceGroupingPre)) {
-                        throw new InferenceException("Grouping " + groupingName + " was not resovled.", usesNode
-                                .getStatementSourceReference());
+                        throw new InferenceException("Grouping " + groupingName + " was not resovled.", usesNode.getStatementSourceReference());
                     }
                     throw new InferenceException("Unknown error occurred.", usesNode.getStatementSourceReference());
                 }
-
             });
-
         }
 
         @Override
index 456d124a5d774c352901f7634404b9dc1cf391c0..48131623a15d624ca8715877ee1b1f244ac5eafc 100644 (file)
@@ -29,7 +29,6 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
 import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
@@ -42,14 +41,19 @@ import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToModuleIdenti
 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleIdentifierToModuleQName;
 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
 import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
 
 import com.google.common.base.CharMatcher;
 import com.google.common.base.Splitter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-public class Utils {
+public final class Utils {
 
+    private Utils() {
+    }
+
+    private static final Logger LOG = LoggerFactory.getLogger(Utils.class);
     private static final CharMatcher DOUBLE_QUOTE_MATCHER = CharMatcher.is('"');
     private static final CharMatcher SINGLE_QUOTE_MATCHER = CharMatcher.is('\'');
 
@@ -57,14 +61,6 @@ public class Utils {
 
     private static final String REGEX_PATH_ABS = "/[^/].+";
 
-    public static final StatementSourceReference CONTEXT_REF = new StatementSourceReference() {
-
-        @Override
-        public StatementSource getStatementSource() {
-            return StatementSource.CONTEXT;
-        }
-    };
-
     public static List<String> splitPathToNodeNames(String path) {
 
         Splitter keySplitter = Splitter.on(SEPARATOR_NODENAME).omitEmptyStrings().trimResults();
@@ -78,7 +74,7 @@ public class Utils {
         try {
             xPath.compile(path);
         } catch (XPathExpressionException e) {
-            throw new IllegalArgumentException("An argument is not valid XPath string");
+            throw new IllegalArgumentException("Argument is not valid XPath string", e);
         }
     }
 
@@ -138,7 +134,7 @@ public class Utils {
         try {
             qNameModule = QNameModule.create(new URI(""), new Date(0));
         } catch (URISyntaxException e) {
-            e.printStackTrace();
+            LOG.warn(e.getMessage(), e);
         }
         String localName = null;
 
@@ -227,8 +223,9 @@ public class Utils {
             if (argument instanceof QName) {
                 QName qname = (QName) argument;
                 qNamesFromRoot.add(qname);
-            } else
+            } else {
                 return SchemaPath.SAME;
+            }
         }
 
         return SchemaPath.create(qNamesFromRoot, true);
index 7e2841452c8b9823edf739b83406cade4f289d81..210a837f81576413d58fc05b9bdd7ff3b3762f6c 100644 (file)
@@ -14,11 +14,14 @@ import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementWriter;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URISyntaxException;
 
 /**
  *
@@ -27,11 +30,20 @@ import java.io.InputStream;
  *
  */
 
-public class YangStatementSourceImpl implements StatementStreamSource {
+public final class YangStatementSourceImpl implements StatementStreamSource {
 
     private YangStatementParserListenerImpl yangStatementModelParser;
     private YangStatementParser.StatementContext statementContext;
     private ParseTreeWalker walker;
+    private static final Logger LOG = LoggerFactory.getLogger(YangStatementSourceImpl.class);
+
+    private static final StatementSourceReference REF = new StatementSourceReference() {
+
+        @Override
+        public StatementSource getStatementSource() {
+            return StatementSource.DECLARATION;
+        }
+    };
 
     public YangStatementSourceImpl(String fileName) {
         try {
@@ -39,18 +51,10 @@ public class YangStatementSourceImpl implements StatementStreamSource {
             walker = new ParseTreeWalker();
             yangStatementModelParser = new YangStatementParserListenerImpl(REF);
         } catch (Exception e) {
-            e.printStackTrace();
+            LOG.warn(e.getMessage(), e);
         }
     }
 
-    private StatementSourceReference REF = new StatementSourceReference() {
-
-        @Override
-        public StatementSource getStatementSource() {
-            return StatementSource.DECLARATION;
-        }
-    };
-
     @Override
     public void writeLinkage(StatementWriter writer, QNameToStatementDefinition stmtDef) throws SourceException {
         yangStatementModelParser.setAttributes(writer, stmtDef);
@@ -69,7 +73,7 @@ public class YangStatementSourceImpl implements StatementStreamSource {
         walker.walk(yangStatementModelParser, statementContext);
     }
 
-    private FileInputStream loadFile(String fileName) throws Exception {
+    private FileInputStream loadFile(String fileName) throws URISyntaxException, FileNotFoundException {
         return new FileInputStream(new File(getClass().getResource(fileName).toURI()));
     }
 
@@ -77,7 +81,6 @@ public class YangStatementSourceImpl implements StatementStreamSource {
         final YangStatementLexer lexer = new YangStatementLexer(new ANTLRInputStream(stream));
         final CommonTokenStream tokens = new CommonTokenStream(lexer);
         final YangStatementParser parser = new YangStatementParser(tokens);
-        final YangStatementParser.StatementContext result = parser.statement();
-        return result;
+        return parser.statement();
     }
 }