ottlinger commented on code in PR #695:
URL: https://github.com/apache/creadur-rat/pull/695#discussion_r3532113483


##########
apache-rat-core/src/main/java/org/apache/rat/ReportConfiguration.java:
##########
@@ -843,4 +866,46 @@ public void validate(final Consumer<String> logger) {
             throw new ConfigurationException(msg);
         }
     }
+
+    /**
+     * An IODescriptor comprises a name and an IOSupplier.  The name should 
identify the contents of the stream.
+     * @param name the name of the supplier.
+     * @param ioSupplier the IOSupplier that provides either an InputStream or 
an OutputStream
+     * @param <T> either InputStream or OutputStream.
+     */
+    public record IODescriptor<T>(String name, IOSupplier<T> ioSupplier) {
+
+        // OUTPUT CONSTRUCTORS
+
+        /**
+         * Creates an output IODescriptor for the file name within the working 
directory.
+         * @param name the name of the file to open.
+         * @param workingDirectory the working directory for the file.
+         * @return the Output IODescriptor.
+         */
+        static IODescriptor<OutputStream> output(final String name, final 
DocumentName workingDirectory) {
+            DocumentName docName = workingDirectory.resolve(name);
+            return new IODescriptor<>(name, () -> new 
FileOutputStream(docName.asFile()));
+        }
+
+        /**
+         * Creates an output IODescriptor for the file.  Does not modify for 
working directory..
+         * @param file the file to open.
+         * @return the Output IODescriptor.
+         */
+        static IODescriptor<OutputStream> output(final File file) {
+            return new IODescriptor<>(file.toString(), () -> new 
FileOutputStream(file, true));
+        }
+
+        // INPUT CONSTRUCTORS
+
+        /**
+         * Creates an input IODescriptor for the file.  Does not modify for 
working directory.
+         * @param file the file to open.
+         * @return the Input IODescriptor.
+         */
+        static IODescriptor<InputStream> input(final File file) {

Review Comment:
   I assume some of these (currently unused methods) will come in handy with 
new PRs, right?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to