com.github.thorbenkuck.network.stream.DataStream Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of easy-net Show documentation
Show all versions of easy-net Show documentation
An EventStream driven, simple to use Client/Server framework
The newest version!
package com.github.thorbenkuck.network.stream;
public interface DataStream extends EventStream, Sink {
static DataStream wrap(DataStream eventStream) {
if (!(eventStream instanceof ManagedEventStream)) {
throw new IllegalArgumentException("A ManagedEventStream is required!");
}
return new DelegatingEventStream((ManagedEventStream) eventStream);
}
static DataStream sequential() {
return new SimpleEventStream<>();
}
static DataStream strict() {
return new StrictEventStream<>();
}
static DataStream parallel() {
return new ParallelEventStream<>();
}
static DataStream of(Source extends T> source) {
DataStream dataStream = sequential();
source.onEmit(dataStream::push);
return dataStream;
}
void push(T t);
void pushError(Throwable throwable);
}