BUG-4688: align Optional/nullable Date usage
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / leafref / LeafRefPathParserImpl.java
index e7d03c14fe0a7b3f73cb67d3cac52e6059361814..f7f316b752536a8c9c5f97921f86e87efcfd03ec 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.yangtools.yang.data.impl.leafref;
 
 import java.io.IOException;
 import java.io.InputStream;
-import org.antlr.v4.runtime.ANTLRInputStream;
+import org.antlr.v4.runtime.CharStreams;
 import org.antlr.v4.runtime.CommonTokenStream;
 import org.antlr.v4.runtime.tree.ParseTreeWalker;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefPathParser.Path_argContext;
@@ -22,28 +22,27 @@ final class LeafRefPathParserImpl {
     private final Module module;
     private final SchemaNode node;
 
-     public LeafRefPathParserImpl(final SchemaContext schemaContext, final Module currentModule, final SchemaNode currentNode) {
+    LeafRefPathParserImpl(final SchemaContext schemaContext, final Module currentModule, final SchemaNode currentNode) {
         this.schemaContext = schemaContext;
         this.module = currentModule;
         this.node = currentNode;
     }
 
-    public LeafRefPath parseLeafRefPathSourceToSchemaPath(final InputStream stream) throws IOException, LeafRefYangSyntaxErrorException {
-
+    public LeafRefPath parseLeafRefPathSourceToSchemaPath(final InputStream stream) throws IOException,
+            LeafRefYangSyntaxErrorException {
         final Path_argContext pathCtx = parseLeafRefPathSource(stream);
 
         final ParseTreeWalker walker = new ParseTreeWalker();
-        final LeafRefPathParserListenerImpl leafRefPathParserListenerImpl = new LeafRefPathParserListenerImpl(schemaContext, module, node);
-        walker.walk(leafRefPathParserListenerImpl,pathCtx);
-
-        final LeafRefPath leafRefPath = leafRefPathParserListenerImpl.getLeafRefPath();
+        final LeafRefPathParserListenerImpl leafRefPathParserListenerImpl = new LeafRefPathParserListenerImpl(
+            schemaContext, module, node);
+        walker.walk(leafRefPathParserListenerImpl, pathCtx);
 
-        return leafRefPath;
+        return leafRefPathParserListenerImpl.getLeafRefPath();
     }
 
-
-    private Path_argContext parseLeafRefPathSource(final InputStream stream) throws IOException, LeafRefYangSyntaxErrorException {
-        final LeafRefPathLexer lexer = new LeafRefPathLexer(new ANTLRInputStream(stream));
+    private Path_argContext parseLeafRefPathSource(final InputStream stream) throws IOException,
+            LeafRefYangSyntaxErrorException {
+        final LeafRefPathLexer lexer = new LeafRefPathLexer(CharStreams.fromStream(stream));
         final CommonTokenStream tokens = new CommonTokenStream(lexer);
         final LeafRefPathParser parser = new LeafRefPathParser(tokens);
         parser.removeErrorListeners();
@@ -53,8 +52,6 @@ final class LeafRefPathParserImpl {
 
         final Path_argContext result = parser.path_arg();
         errorListener.validate();
-
         return result;
     }
-
 }