public class StreamUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
StreamUtil.ThrowableRunnable
Runnable that throw some exception
|
| Modifier and Type | Method and Description |
|---|---|
static Stream<Throwable> |
causes(Throwable throwable) |
static Stream<Path> |
directories(Path directory)
Finds directories within a given directory and its subdirectories.
|
static Stream<Path> |
directories(Path directory,
DirectoryStream.Filter<Path> filter)
Finds directories within a given directory and its subdirectories.
|
static Stream<Path> |
directories(Path directory,
String glob)
Finds directories within a given directory and its subdirectories.
|
static Stream<Path> |
directoriesAndFiles(Path directory)
Finds directories within a given directory and its subdirectories.
|
static Stream<Path> |
directoriesAndFiles(Path directory,
DirectoryStream.Filter<Path> filter)
Finds directories and files within a given directory and its subdirectories.
|
static Stream<Path> |
directoriesAndFiles(Path directory,
String glob)
Finds directories and files within a given directory and its subdirectories.
|
static Stream<Path> |
files(Path directory)
Finds files within a given directory and its subdirectories.
|
static Stream<Path> |
files(Path directory,
DirectoryStream.Filter<Path> filter)
Finds files within a given directory and its subdirectories.
|
static Stream<Path> |
files(Path directory,
String glob)
Finds files within a given directory and its subdirectories.
|
static <T> Stream<T> |
fromIterator(Iterator<T> iterator) |
static <T> Stream<T> |
fromIterator(Iterator<T> iterator,
int characteristics) |
static <T> Iterator<T> |
iteratorFilter(Iterator<T> iterator,
Predicate<? super T> predicate)
Returns an iterator consisting of the elements of this stream that match
the given predicate.
|
static <T,R> Iterator<R> |
iteratorFlatMap(Iterator<T> iterator,
Function<? super T,? extends Iterator<? extends R>> mapper)
Returns an iterator consisting of the results of replacing each element of
this iterator with the contents of a mapped iterator produced by applying
the provided mapping function to each element.
|
static <T,R> Iterator<R> |
iteratorMap(Iterator<T> iterator,
Function<? super T,? extends R> mapper)
Returns an iterator consisting of the results of applying the given
function to the elements of this iterator.
|
static Stream<String> |
matchGroups(Matcher matcher) |
static Stream<String> |
matchGroups(Matcher matcher,
int group) |
static Stream<MatchResult> |
matchResults(Matcher matcher) |
static <T> Stream<T> |
nullable(T value) |
static <T> Stream<T> |
optional(Optional<T> optional) |
static <T> T |
resultNull(Runnable runnable)
Executes runnable then return null of required type
|
static <T> void |
resultVoid(Supplier<T> supplier)
Executes something that returns result and ignore result
|
static <R,T extends Throwable> |
sneakyThrow(Throwable ex)
Throws checked exceptions like unchecked ones
|
static <T> Stream<T> |
supply(Supplier<T> supplier) |
static <R> R |
unchecked(Callable<R> callable)
Prevent necessity to check exceptions from lambdas that return some result
|
static void |
unchecked(StreamUtil.ThrowableRunnable runnable)
Prevent necessity to check exceptions from lambdas that don't return any result
|
static <T> T |
uncheckedNull(StreamUtil.ThrowableRunnable runnable)
Prevent necessity to check exceptions from lambdas that don't return any result,
then return null of required type
|
static <R> void |
uncheckedVoid(Callable<R> callable)
Prevent necessity to check exceptions from lambdas that return some result and ignore result
|
public static <T> Stream<T> nullable(T value)
public static Stream<MatchResult> matchResults(Matcher matcher)
public static Stream<Path> files(Path directory)
public static Stream<Path> files(Path directory, String glob)
public static Stream<Path> files(Path directory, DirectoryStream.Filter<Path> filter)
public static Stream<Path> directories(Path directory)
public static Stream<Path> directories(Path directory, String glob)
public static Stream<Path> directories(Path directory, DirectoryStream.Filter<Path> filter)
public static Stream<Path> directoriesAndFiles(Path directory)
public static Stream<Path> directoriesAndFiles(Path directory, String glob)
public static Stream<Path> directoriesAndFiles(Path directory, DirectoryStream.Filter<Path> filter)
public static <R,T extends Throwable> R sneakyThrow(Throwable ex) throws T extends Throwable
R - fake result typeT - exception typeex - any exceptionTT extends Throwablepublic static <R> R unchecked(Callable<R> callable)
R - result typecallable - some lambda throwing checked exceptionpublic static void unchecked(StreamUtil.ThrowableRunnable runnable)
runnable - some lambda throwing checked exceptionpublic static <T> T uncheckedNull(StreamUtil.ThrowableRunnable runnable)
T - return value typerunnable - some lambda throwing checked exceptionpublic static <R> void uncheckedVoid(Callable<R> callable)
R - ignored result typecallable - some lambda throwing checked exceptionpublic static <T> T resultNull(Runnable runnable)
T - return value typerunnable - some codepublic static <T> void resultVoid(Supplier<T> supplier)
T - ignored result typesupplier - Something that returns resultpublic static <T,R> Iterator<R> iteratorMap(Iterator<T> iterator, Function<? super T,? extends R> mapper)
iterator - source iteratormapper - function to apply to each elementpublic static <T> Iterator<T> iteratorFilter(Iterator<T> iterator, Predicate<? super T> predicate)
iterator - source iteratorpredicate - predicate to apply to each element to determine if it should be includedpublic static <T,R> Iterator<R> iteratorFlatMap(Iterator<T> iterator, Function<? super T,? extends Iterator<? extends R>> mapper)
iterator - source iteratormapper - function to apply to each elementCopyright © 2018. All rights reserved.