SwitchIfEmptyExtension<T> extension

Extend the Stream class with the ability to return an alternative Stream if the initial Stream completes with no items.

on

Methods

switchIfEmpty(Stream<T> fallbackStream) Stream<T>

Available on Stream<T>, provided by the SwitchIfEmptyExtension extension

When the original Stream emits no items, this operator subscribes to the given fallback stream and emits items from that Stream instead.