Interface Streamer<V,​T>

  • Type Parameters:
    V - The type of the store from which to stream items
    T - The item type to stream
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface Streamer<V,​T>
    A streamer returns a stream of items from a collection-like object (referred to as a 'store') given as the argument. For example, in the case of a map data structure a streamer may return any of its key, value or entry set. If the actual type of the collection is not known the {streamRaw(Object) method should be used.
    Author:
    Claus Stadler 11/09/2020
    • Method Detail

      • stream

        java.util.stream.Stream<T> stream​(V store)
      • mapStream

        default <U> Streamer<V,​U> mapStream​(StreamTransform<T,​U> streamTransform)
        Convenience method that yields a new Streamer that wraps this streamer such that its streams are transformed by the given streamTransform.
        Type Parameters:
        U -
        Parameters:
        streamTransform -
        Returns:
      • mapItems

        default <U> Streamer<V,​U> mapItems​(java.util.function.Function<T,​U> itemTransform)
        Convenience method to derive a new streamer that transforms the items emitted by the original streamer.
        Type Parameters:
        U -
        Parameters:
        itemTransform -
        Returns:
      • streamRaw

        default java.util.stream.Stream<T> streamRaw​(Object store)
        Delegate to stream(Object).
        Parameters:
        store -
        Returns:
        A stream from given store. Arguments of incorrect type will cause a ClassCastException.