/** * @param stream stream of events * @param <S> state type * @return event stream with a state set to <code>null</code> and a stream */ public static <S> EventStream<S> of(Stream<? extends Event> stream) { return new EventStream<>(null, stream); }
/** * @param state state * @param stream stream of events * @param <S> state type * @return event stream with a state and a stream */ public static <S> EventStream<S> ofWithState(S state, Stream<? extends Event> stream) { return new EventStream<>(state, stream); }
/** * @param state state * @param event event * @param <S> state type * @return event stream with a state and a stream of one event */ public static <S> EventStream<S> ofWithState(S state, Event event) { return new EventStream<>(state, Stream.of(event)); }
/** * @param <S> state type * @return empty event stream with state set to <code>null</code> */ public static <S> EventStream<S> empty() { return new EventStream<>(null, Stream.empty()); }
/** * @param state state * @param <S> state type * @return empty event stream with a state */ public static <S> EventStream<S> empty(S state) { return new EventStream<>(state, Stream.empty()); }
/** * @param state state * @param events events * @param <S> state type * @return event stream with a state and a stream of multiple events */ public static <S> EventStream<S> ofWithState(S state, Event ...events) { return new EventStream<>(state, Stream.of(events)); }
/** * * @param events events * @param <S> state type * @return event stream with a state set to <code>null</code> and a stream of multiple events */ public static <S> EventStream<S> of(Event ...events) { return new EventStream<>(null, Stream.of(events)); }
/** * @param event event * @param <S> state type * @return event stream with a state set to <code>null</code> and a stream of one event */ public static <S> EventStream<S> of(Event event) { return new EventStream<>(null, Stream.of(event)); }
public EventStream<S> build() { return new EventStream<>(state, builder.build()); } }