- java.lang.Object
-
- io.annot8.common.utils.java.StreamUtils
-
public final class StreamUtils extends Object
Utilities for working with streams
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Stream<T>append(Stream<T> stream, T... objects)static <T,S extends T>
Stream<S>cast(Stream<T> stream, Class<S> clazz)Filter out items in the stream that aren't a subclass of clazzstatic <T> Stream<T>getIfPresent(Stream<Optional<T>> stream)Extract optional which are present
-
-
-
Method Detail
-
cast
public static <T,S extends T> Stream<S> cast(Stream<T> stream, Class<S> clazz)
Filter out items in the stream that aren't a subclass of clazz- Type Parameters:
T- input of the streamS- output of the stream- Parameters:
stream- the streamclazz- the class to filter and cast on on- Returns:
- stream of just clazz implementations
-
getIfPresent
public static <T> Stream<T> getIfPresent(Stream<Optional<T>> stream)
Extract optional which are present- Type Parameters:
T- content of stream- Parameters:
stream- the stream- Returns:
- stream of non-null (present optionals)
-
-