Interface Streamable<E>

Type Parameters:
E - The type of contained elements.
All Known Subinterfaces:
Streamer<E>
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 Streamable<E>
Represents instances that (virtually or really) contain elements of a specific type and can provide a Stream over those elements when needed.
See Also:
  • Method Details

    • empty

      static <E> Streamable<E> empty()
      Returns a Streamable that is empty.
      Type Parameters:
      E - The type of virtually contained elements.
    • of

      static <E> Streamable<E> of(E element)
      Returns a Streamable that contains a single given element.
      Type Parameters:
      E - The type of the contained element.
    • of

      @SafeVarargs static <E> Streamable<E> of(E element0, E element1, E... more)
      Returns a Streamable that contains two or more given elements.
      Type Parameters:
      E - The type of the contained elements.
    • of

      static <E> Streamable<E> of(E[] elements)
      Returns a Streamable backed by an array of elements.
      Type Parameters:
      E - The type of the contained elements.
    • of

      static <E> Streamable<E> of(Iterable<E> iterable)
      Returns a Streamable backed by a given Iterable.
      Type Parameters:
      E - The type of the contained elements.
    • stream

      Stream<E> stream()
      Returns a sequential Stream with this Streamable as its source.

      An implementation may or may not specify a streaming order.

    • isEmpty

      default boolean isEmpty()
      Returns true if this Streamable contains no element.
    • containsAny

      default boolean containsAny()
      Returns true if this Streamable contains any element.
    • containsAny

      default boolean containsAny(Predicate<? super E> condition)
      Returns true if this Streamable contains at least one element such that condition.test(element) is true.
      Throws:
      NullPointerException - if the specified condition is null.
    • containsAll

      default boolean containsAll(Predicate<? super E> condition)
      Returns true if this Streamable contains elements such that condition.test(element) is true for each element.
      Throws:
      NullPointerException - if the specified condition is null.
    • contains

      default boolean contains(Object candidate)
      Returns true if this Streamable contains at least one element such that Objects.equals(element, candidate).
    • containsAny

      default <X> boolean containsAny(Streamable<X> other)
      Returns true if this Streamable contains any element of the specified other Streamable.
      Throws:
      NullPointerException - if the specified other Streamable is null.
    • containsAll

      default <X> boolean containsAll(Streamable<X> other)
      Returns true if this Streamable contains all elements of the specified other Streamable.
      Throws:
      NullPointerException - if the specified other Streamable is null.
    • forEach

      default void forEach(Consumer<? super E> action)
      Performs the given action for each element of this Streamable until all elements have been processed or the action throws an (unchecked) exception. Actions are performed in the streaming order, if that order is specified. Exceptions thrown by the action are relayed to the caller.
      Throws:
      NullPointerException - if the specified action is null.