org.qbicc.machine.tool.process.InputStreamSupplierInputSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of qbicc-machine-tool-api Show documentation
Show all versions of qbicc-machine-tool-api Show documentation
The API for Qbicc machine tooling support
package org.qbicc.machine.tool.process;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import io.smallrye.common.function.ExceptionFunction;
final class InputStreamSupplierInputSource extends InputSource {
private final ExceptionFunction function;
private final T param;
InputStreamSupplierInputSource(final ExceptionFunction function, final T param) {
this.function = function;
this.param = param;
}
public void transferTo(final OutputDestination destination) throws IOException {
destination.transferFrom(this);
}
ProcessBuilder.Redirect getInputRedirect() {
return ProcessBuilder.Redirect.PIPE;
}
void writeTo(final Path path) throws IOException {
try (InputStream is = openStream()) {
Files.copy(is, path, StandardCopyOption.REPLACE_EXISTING);
}
}
@Override
public String toString() {
return "";
}
ExceptionFunction getFunction() {
return function;
}
T getParam() {
return param;
}
InputStream openStream() throws IOException {
return function.apply(param);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy