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

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

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

import static java.util.Objects.requireNonNull;

class BasicProcessResult implements ProcessResult {

    private final int exitCode;
    private final StreamContent output;

    public BasicProcessResult(int exitCode, StreamContent output) {
        this.exitCode = exitCode;
        this.output = requireNonNull(output);
    }

    @Override
    public int exitCode() {
        return exitCode;
    }

    @Override
    public StreamContent content() {
        return output;
    }

    public static  BasicProcessResult withNoOutput(int exitCode) {
        return new BasicProcessResult<>(exitCode, StreamContents.bothNull());
    }

    public static  BasicProcessResult create(int exitCode, SO stdout, SE stderr) {
        return new BasicProcessResult<>(exitCode, StreamContent.direct(stdout, stderr));
    }

    @Override
    public String toString() {
        return "ProcessResult{" +
                "exitCode=" + exitCode +
                ", output=" + output +
                '}';
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy