All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.mike10004.nativehelper.subprocess.StreamContent Maven / Gradle / Ivy

There is a newer version: 10.0.0
Show newest version
package com.github.mike10004.nativehelper.subprocess;

import com.github.mike10004.nativehelper.subprocess.StreamContents.MappedOutput;

import java.util.function.Function;

/**
 * Interface defining methods for obtaining the captured content of
 * standard output and error streams of a process.
 * @param  type of captured standard output contents
 * @param  type of captured standard error contents
 */
public interface StreamContent {

    /**
     * Returns the content written to standard output by a process.
     * @return the standard output content
     */
    SO stdout();

    /**
     * Returns the content written to standard error by a process.
     * @return the standard error content
     */
    SE stderr();

    static  StreamContent direct(SO stdout, SE stderr) {
        return new StreamContents.DirectOutput<>(stdout, stderr);
    }

    default  StreamContent map(Function stdoutMap, Function stderrMap) {
        return new MappedOutput<>(this, stdoutMap, stderrMap);
    }

    static  StreamContent empty() {
        return StreamContents.bothNull();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy