com.github.zella.rxprocess2.BaseReactiveProcessBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rx-process2 Show documentation
Show all versions of rx-process2 Show documentation
rx-java2 wrapper for NuProcess
The newest version!
package com.github.zella.rxprocess2;
import com.github.zella.rxprocess2.common.RxUtils;
import io.reactivex.Observable;
import io.reactivex.Single;
import java.util.concurrent.TimeUnit;
import static com.github.zella.rxprocess2.RxProcessConfig.DEFAULT_PROCESS_TIMEOUT_MILLIS;
public abstract class BaseReactiveProcessBuilder implements IReactiveProcessBuilder {
protected byte[] stdin = {};
@Override
public IReactiveProcessBuilder withStdin(byte[] data) {
this.stdin = data;
return this;
}
@Override
public Single asWaitDone() {
return asWaitDone(DEFAULT_PROCESS_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
}
@Override
public Single asStdOutSingle(long timeout, TimeUnit timeUnit) {
return RxUtils.collect(asStdErrOut(timeout, timeUnit)
.filter(c -> !c.isStdErr)
.map(c -> c.data));
}
@Override
public Single asStdOutSingle() {
return asStdOutSingle(DEFAULT_PROCESS_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
}
@Override
public Observable asStdErrOut() {
return asStdErrOut(DEFAULT_PROCESS_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
}
@Override
public Observable asStdOut(long timeout, TimeUnit timeUnit) {
return asStdErrOut(timeout, timeUnit).filter(c -> !c.isStdErr).map(c -> c.data);
}
@Override
public Observable asStdOut() {
return asStdOut(DEFAULT_PROCESS_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy