public final class ExceptionalFunctionUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T,R extends AutoCloseable> |
tryWithResources(ExceptionalResourceSupplier<R> resourceSupplier,
ExceptionalFunction<R,T,Exception> consumer)
Functional try-with-resources with default exception translator function
|
static <T,R extends AutoCloseable> |
tryWithResources(ExceptionalResourceSupplier<R> resourceSupplier,
ExceptionalFunction<R,T,Exception> consumer,
RuntimeExceptionFunction runtimeExceptionFunction)
Functional try-with-resources with exception translator function
|
static <T,R extends AutoCloseable> |
tryWithResources(ExceptionalResourceSupplier<R> resourceSupplier,
ExceptionalFunction<R,T,Exception> consumer,
Supplier<T> fallbackSupplier)
Functional try-with-resources
|
public static <T,R extends AutoCloseable> T tryWithResources(ExceptionalResourceSupplier<R> resourceSupplier, ExceptionalFunction<R,T,Exception> consumer, Supplier<T> fallbackSupplier)
T - Type of the resultR - Type of the AutoCloseable resourceresourceSupplier - supplier for the AutoCloseable resourceconsumer - function that consumes the resource and returns a valuefallbackSupplier - supplier for a fallback valuepublic static <T,R extends AutoCloseable> T tryWithResources(ExceptionalResourceSupplier<R> resourceSupplier, ExceptionalFunction<R,T,Exception> consumer, RuntimeExceptionFunction runtimeExceptionFunction)
T - Type of the resultR - Type of the AutoCloseable resourceresourceSupplier - supplier for the AutoCloseable resourceconsumer - function that consumes the resource and returns a valueruntimeExceptionFunction - function that converts Exception to RuntimeExceptionpublic static <T,R extends AutoCloseable> T tryWithResources(ExceptionalResourceSupplier<R> resourceSupplier, ExceptionalFunction<R,T,Exception> consumer)
T - Type of the resultR - Type of the AutoCloseable resourceresourceSupplier - supplier for the AutoCloseable resourceconsumer - function that consumes the resource and returns a valueCopyright © 2020. All rights reserved.