Fixup listFiles() 31/104631/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 28 Feb 2023 21:10:27 +0000 (22:10 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 28 Feb 2023 21:11:12 +0000 (22:11 +0100)
Use ImmutableList for return to make interactions clear.

Change-Id: I8e3955b99913b5286541d78e926584e9b004aa23
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
plugin/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesProcessor.java

index e43271d4efeacfe89e9b21b9500ded9bc46430a7..31adc97177714874ebc82c8a80494d95d98939a8 100644 (file)
@@ -351,20 +351,25 @@ class YangToSourcesProcessor {
         }
     }
 
-    private static List<File> listFiles(final File root, final Collection<File> excludedFiles)
+    private static ImmutableList<File> listFiles(final File root, final Collection<File> excludedFiles)
             throws IOException {
         if (!root.isDirectory()) {
             LOG.warn("{} YANG source directory {} not found. No code will be generated.", LOG_PREFIX, root);
             return ImmutableList.of();
         }
 
-        return Files.walk(root.toPath()).map(Path::toFile).filter(File::isFile).filter(f -> {
-            if (excludedFiles.contains(f)) {
-                LOG.info("{} YANG file excluded {}", LOG_PREFIX, f);
-                return false;
-            }
-            return true;
-        }).filter(f -> f.getName().endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION)).collect(Collectors.toList());
+        return Files.walk(root.toPath())
+            .map(Path::toFile)
+            .filter(File::isFile)
+            .filter(f -> {
+                if (excludedFiles.contains(f)) {
+                    LOG.info("{} YANG file excluded {}", LOG_PREFIX, f);
+                    return false;
+                }
+                return true;
+            })
+            .filter(f -> f.getName().endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION))
+            .collect(ImmutableList.toImmutableList());
     }
 
     /**