public final class FunctionalUtils extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
FunctionalUtils.UnsafeConsumer<I>
Equivalent of
Consumer that throws a checked exception. |
static interface |
FunctionalUtils.UnsafeFunction<T,R>
Equivalent of
Function that throws a checked exception. |
static interface |
FunctionalUtils.UnsafeRunnable
Equivalent of
Runnable that throws a checked exception. |
static interface |
FunctionalUtils.UnsafeSupplier<T>
Equivalent of
Supplier that throws a checked exception. |
Modifier and Type | Method and Description |
---|---|
static void |
invokeSafely(FunctionalUtils.UnsafeRunnable unsafeRunnable) |
static <T> T |
invokeSafely(FunctionalUtils.UnsafeSupplier<T> unsafeSupplier) |
static <I> Consumer<I> |
safeConsumer(FunctionalUtils.UnsafeConsumer<I> unsafeConsumer)
A wrapper around a Consumer that throws a checked exception.
|
static <T,R> Function<T,R> |
safeFunction(FunctionalUtils.UnsafeFunction<T,R> unsafeFunction)
Takes a functional interface that throws an exception and returns a
Function that deals with that exception by
wrapping in a runtime exception. |
static Runnable |
safeRunnable(FunctionalUtils.UnsafeRunnable unsafeRunnable)
A wrapper around a Runnable that throws a checked exception.
|
static <T> Supplier<T> |
safeSupplier(FunctionalUtils.UnsafeSupplier<T> unsafeSupplier)
A wrapper around a BiConsumer that throws a checked exception.
|
static <I,O> Function<I,O> |
toFunction(Supplier<O> supplier) |
public static <I> Consumer<I> safeConsumer(FunctionalUtils.UnsafeConsumer<I> unsafeConsumer)
unsafeConsumer
- - something that acts like a consumer but throws an exceptionpublic static <T,R> Function<T,R> safeFunction(FunctionalUtils.UnsafeFunction<T,R> unsafeFunction)
Function
that deals with that exception by
wrapping in a runtime exception. Useful for APIs that use the standard Java functional interfaces that don't throw checked
exceptions.T
- InputR
- OutputunsafeFunction
- Functional interface that throws checked exception.Function
that handles checked exception.public static <T> Supplier<T> safeSupplier(FunctionalUtils.UnsafeSupplier<T> unsafeSupplier)
unsafeSupplier
- - something that acts like a BiConsumer but throws an exceptionpublic static Runnable safeRunnable(FunctionalUtils.UnsafeRunnable unsafeRunnable)
unsafeRunnable
- Something that acts like a Runnable but throws an exceptionpublic static <T> T invokeSafely(FunctionalUtils.UnsafeSupplier<T> unsafeSupplier)
public static void invokeSafely(FunctionalUtils.UnsafeRunnable unsafeRunnable)
Copyright © 2017 Amazon Web Services, Inc. All Rights Reserved.