java.util.stream package, or more generally, with Java 8 lambdas. More specifically, it
attempts to address the fact that lambdas are supposed not to throw Exceptions, at least not checked Exceptions, AKA instances of Exception. This
enforces the use of constructs like:
Consumer<java.lang.reflect.Method> consumer = m -> {
try {
m.invoke(o, args);
} catch (Throwable t) {
throw Failable.rethrow(t);
}
};
stream.forEach(consumer);
Using a FailableStream, this can be rewritten as follows:
Streams.failable(stream).forEach(m -> m.invoke(o, args));
Obviously, the second version is much more concise and the spirit of Lambda expressions is met better than in the first version.
Stream, Failable
| Modifier and Type | Class and Description |
|---|---|
| public static class | |
| private static class | |
| public static class | Streams.
The streams element type. T>A reduced, and simplified version of a |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static < The streams element type. T> Streams. | Returns: TheFailableStream, which has been created by converting the stream.The stream, which is being converted. stream)Converts the given |
| public static < The streams element type. T> Streams. | Returns: TheFailableStream, which has been created by converting the stream.The stream, which is being converted. stream)Converts the given |
| public static < the type of stream elements. T> Streams. | Returns: the new FailableStream onvalue or an empty stream.the single element of the new stream, may be value)null.Shorthand for |
| public static < the type of stream elements. T> Streams. | Returns: the new FailableStream onvalues or an empty stream.the elements of the new stream, may be values)null.Shorthand for |
| public static < the type of elements in the collection we want to stream. E> Stream | Returns: A non-null stream that only provides instances we want.the type of elements in the collection we want to stream. clazz, final Collection<? super E> the collection to stream or null. collection)Streams only instances of the give Class in a collection. |
| private static <E> Stream | |
| public static < the type of elements in the collection. E> Stream | Returns: A non-null stream that filters out null elements.the collection to stream or null. collection)Streams the non-null elements of a collection. |
| public static < the type of elements in the collection. E> Stream | Returns: A non-null stream that filters out a null element.the element to stream or null. array)Streams the non-null element. |
| public static < the type of elements in the collection. E> Stream | Returns: A non-null stream that filters out null elements.the array to stream or null. array)Streams the non-null elements of an array. |
| public static < the type of elements in the collection. E> Stream | |
| public static < the type of elements in the collection. E> Stream | of(final Collection<E>
the collection to stream or null. collection)Delegates to |
| public static < The enumeration element type. E> Stream | Returns: a new stream.The enumeration to stream. enumeration)Streams the elements of the given enumeration in order. |
| public static < the type of elements in the Iterable. E> Stream | Returns: a new Stream orStream#empty() if the Iterable is null.the Iterable to stream or null. iterable)Creates a sequential stream on the given Iterable. |
| public static < the type of elements in the Iterator. E> Stream | Returns: a new Stream orStream#empty() if the Iterator is null.the Iterator to stream or null. iterator)Creates a sequential stream on the given Iterator. |
| private static < the type of elements in the collection. E> Stream | Returns: the stream orStream#empty() if the stream is null.the stream to stream or null. stream)Returns the stream or |
| public static < the type of stream elements. T> Stream | of(final T...
the elements of the new stream, may be values)null.Null-safe version of |
| public static < The streams element type. E> Streams. | Returns: TheFailableStream, which has been created by converting the stream.The stream, which is being converted. collection)
Deprecated
Use
failableStream(Collection).
Converts the given |
| public static < The streams element type. T> Streams. | Returns: TheFailableStream, which has been created by converting the stream.The stream, which is being converted. stream)
Deprecated
Use
failableStream(Stream).
Converts the given |
| private static <T> Stream | |
| public static < the type of the input elements T> Collector |