public class LambdaSupport
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static <E extends java.lang.Throwable> |
unchecked(Block<? super E> block)
Wrap block as lambda expression without exception, for example:
|
static <R,E extends java.lang.Throwable> |
unchecked(Procedure<R,E> procedure)
Wrap procedure as lambda expression without exception, for example:
|
static <A,B> void |
with(A a,
B b,
java.util.function.BiConsumer<A,B> consumer)
Wrap bi-consumer as lambda expression without exception
|
static <A,B,R> R |
with(A a,
B b,
java.util.function.BiFunction<A,B,R> function)
Wrap bi-function as lambda expression without exception
|
static <T> void |
with(T object,
java.util.function.Consumer<? super T> consumer)
Wrap consumer as lambda expression without exception
|
static <T,R> R |
with(T object,
java.util.function.Function<T,R> function)
Wrap function as lambda expression without exception
|
public static <E extends java.lang.Throwable> void unchecked(Block<? super E> block)
stream.forEach(file -> unchecked(() -> {
FileUtils.readAsString(file);
}));
E - the type of exceptionblock - the consumer lambda to wrappublic static <R,E extends java.lang.Throwable> R unchecked(Procedure<R,E> procedure)
stream.filter(file -> unchecked(() -> {
return FileUtils.readAsString(file).endsWith(".class");
}));
R - the type of resultE - the type of exceptionprocedure - the function lambda to wrappublic static <T> void with(T object,
java.util.function.Consumer<? super T> consumer)
T - The type of argumentobject - the argument of consumerconsumer - the consumer to be wrappedpublic static <T,R> R with(T object,
java.util.function.Function<T,R> function)
T - The type of argumentR - The return type of functionobject - the argument of functionfunction - the function to be wrappedpublic static <A,B> void with(A a,
B b,
java.util.function.BiConsumer<A,B> consumer)
A - The type of first argumentB - The type of second argumenta - The first argument of bi-consumerb - The second argument of bi-consumerconsumer - The bi-consumer to be wrappedpublic static <A,B,R> R with(A a,
B b,
java.util.function.BiFunction<A,B,R> function)
A - The type of first argumentB - The type of second argumentR - The return type of bi-functiona - The first argument of bi-functionb - The second argument of bi-functionfunction - The bi-function to be wrapped