Class FunctionalUtils
java.lang.Object
software.amazon.awssdk.utils.FunctionalUtils
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceEquivalent ofConsumerthat throws a checked exception.static interfaceEquivalent ofFunctionthat throws a checked exception.static interfaceEquivalent ofRunnablethat throws a checked exception.static interfaceEquivalent ofSupplierthat throws a checked exception.
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidinvokeSafely(FunctionalUtils.UnsafeRunnable unsafeRunnable) static <T> TinvokeSafely(FunctionalUtils.UnsafeSupplier<T> unsafeSupplier) static <T> Consumer<T> static Runnablestatic voidrunAndLogError(org.slf4j.Logger log, String errorMsg, FunctionalUtils.UnsafeRunnable runnable) Runs a givenFunctionalUtils.UnsafeRunnableand logs an error without throwing.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 aFunctionthat deals with that exception by wrapping in a runtime exception.static RunnablesafeRunnable(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) 
- 
Method Details- 
runAndLogErrorpublic static void runAndLogError(org.slf4j.Logger log, String errorMsg, FunctionalUtils.UnsafeRunnable runnable) Runs a givenFunctionalUtils.UnsafeRunnableand logs an error without throwing.- Parameters:
- errorMsg- Message to log with exception thrown.
- runnable- Action to perform.
 
- 
noOpConsumer
- 
noOpRunnable
- 
safeConsumerA wrapper around a Consumer that throws a checked exception.- Parameters:
- unsafeConsumer- - something that acts like a consumer but throws an exception
- Returns:
- a consumer that is wrapped in a try-catch converting the checked exception into a runtime exception
 
- 
safeFunctionTakes a functional interface that throws an exception and returns aFunctionthat 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.- Type Parameters:
- T- Input
- R- Output
- Parameters:
- unsafeFunction- Functional interface that throws checked exception.
- Returns:
- New Functionthat handles checked exception.
 
- 
safeSupplierA wrapper around a BiConsumer that throws a checked exception.- Parameters:
- unsafeSupplier- - something that acts like a BiConsumer but throws an exception
- Returns:
- a consumer that is wrapped in a try-catch converting the checked exception into a runtime exception
 
- 
safeRunnableA wrapper around a Runnable that throws a checked exception.- Parameters:
- unsafeRunnable- Something that acts like a Runnable but throws an exception
- Returns:
- A Runnable that is wrapped in a try-catch converting the checked exception into a runtime exception
 
- 
toFunction
- 
invokeSafely
- 
invokeSafely
 
-