Returns a function from Object to Stream , which returns a stream containing its input if its input is an instance of T. Use as an argument to Stream#flatMap(Function): Stream barStream = fooStream.flatMap(instancesOf(Bar.class));
(Class<T> to)
| 73 | * <pre>{@code Stream<Bar>} barStream = fooStream.flatMap(instancesOf(Bar.class));</pre> |
| 74 | */ |
| 75 | public static <T> Function<Object, Stream<T>> instancesOf(Class<T> to) { |
| 76 | return f -> to.isInstance(f) ? Stream.of(to.cast(f)) : Stream.empty(); |
| 77 | } |
| 78 | |
| 79 | private DaggerStreams() {} |
| 80 | } |
no test coverage detected