public final class Lambdas extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Lambdas.CheckedFunction<T,R,E extends Throwable> |
static interface |
Lambdas.CheckedRunnable |
| Modifier and Type | Method and Description |
|---|---|
static <T> java.util.function.Consumer<T> |
as(java.util.function.Consumer<T> consumer)
Returns the given argument as a consumer, usefull when called with method reference.
|
static <T,R> java.util.function.Function<T,R> |
as(java.util.function.Function<T,R> function)
Returns the given argument as a function, usefull when called with method reference.
|
static <T> java.util.function.Predicate<T> |
as(java.util.function.Predicate<T> predicate)
Returns the given argument as a predicate, usefull when called with method reference.
|
static <T> java.util.function.Supplier<T> |
as(java.util.function.Supplier<T> supplier)
Returns the given argument as a supplier, usefull when called with method reference.
|
static void |
mute(Lambdas.CheckedRunnable runnable)
Mute a failure.
|
static <T,R> java.util.function.Function<T,R> |
unchecked(Lambdas.CheckedFunction<T,R,Throwable> function)
Transforms a function throwing a checked exception into an equivalent
throwing a
RuntimeException wrapping the checked one. |
static void |
unchecked(Lambdas.CheckedRunnable runnable)
Mute a failure.
|
public static <T> java.util.function.Predicate<T> as(java.util.function.Predicate<T> predicate)
T - the type of the object used within the predicatepredicate - the argument already resolved by the compiler as a predicatepublic static <T> java.util.function.Consumer<T> as(java.util.function.Consumer<T> consumer)
T - the type of the object consumed by the consumerconsumer - the argument already resolved by the compiler as a consumerpublic static <T> java.util.function.Supplier<T> as(java.util.function.Supplier<T> supplier)
T - the type of the object produced by the suppliersupplier - the argument already resolved by the compiler as a supplierpublic static <T,R> java.util.function.Function<T,R> as(java.util.function.Function<T,R> function)
T - the type of the object consumed by the functionR - the type of the object returned by the functionfunction - the argument already resolved by the compiler as a functionpublic static void mute(Lambdas.CheckedRunnable runnable)
runnable - the runnable able to throw a CheckedExceptionpublic static void unchecked(Lambdas.CheckedRunnable runnable)
runnable - the runnable able to throw a CheckedExceptionpublic static <T,R> java.util.function.Function<T,R> unchecked(Lambdas.CheckedFunction<T,R,Throwable> function)
RuntimeException wrapping the checked one.T - the type of the function inputR - the type of the return value of the functionfunction - the given function to wrapCopyright © 2016–2021 Matthieu Brouillard. All rights reserved.