Yang module source should be always available 48/4848/1
authorRobert Varga <rovarga@cisco.com>
Mon, 27 Jan 2014 08:20:50 +0000 (09:20 +0100)
committerRobert Varga <rovarga@cisco.com>
Mon, 27 Jan 2014 08:20:50 +0000 (09:20 +0100)
Change-Id: Ifed7b030beccae2371c398186550b874d84eff7e
Signed-off-by: Robert Varga <rovarga@cisco.com>
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/YangModuleInfoTemplate.xtend

index fd14d830f2e1cf1fddc0e77ce44c0b10f119d875..8cb900c1952e78adbd2be08e2b715b1e6a6acbb0 100644 (file)
@@ -98,17 +98,15 @@ class YangModuleInfoTemplate {
             «ENDIF»
 
             «val path = m.moduleSourcePath»
-            «IF path != null»
-                «InputStream.importedName» stream = «CLASS».class.getResourceAsStream("«path»");
-                if (stream == null) {
-                    throw new IllegalStateException("Resource «path» is missing");
-                }
-                try {
-                    stream.close();
-                } catch («IOException.importedName» e) {
-                    // Resource leak, but there's nothing we can do
-                }
-            «ENDIF»
+            «InputStream.importedName» stream = «CLASS».class.getResourceAsStream("«path»");
+            if (stream == null) {
+                throw new IllegalStateException("Resource «path» is missing");
+            }
+            try {
+                stream.close();
+            } catch («IOException.importedName» e) {
+                // Resource leak, but there is nothing we can do
+            }
         }
 
         @Override
@@ -129,15 +127,11 @@ class YangModuleInfoTemplate {
 
         @Override
         public «InputStream.importedName» getModuleSourceStream() throws IOException {
-            «IF path == null»
-                return null;
-            «ELSE»
-                «InputStream.importedName» stream = «CLASS».class.getResourceAsStream("«path»");
-                if (stream == null) {
-                    throw new «IOException.importedName»("Resource «path» is missing");
-                }
-                return stream;
-            «ENDIF»
+            «InputStream.importedName» stream = «CLASS».class.getResourceAsStream("«path»");
+            if (stream == null) {
+                throw new «IOException.importedName»("Resource «path» is missing");
+            }
+            return stream;
         }
 
         @Override