T
- some generic flagR
- some generic flagE
- The extension@FunctionalInterface public interface FunctionWithThrowable<T,R,E extends Throwable> extends Function<T,R>
Modifier and Type | Method and Description |
---|---|
static <T,R,E extends Throwable> |
aFunctionThatUnsafelyThrowsUnchecked(FunctionWithThrowable<T,R,E> functionwiththrowable)
Utility method to unwrap lambdas of type Function and withUncheckedThrowable any Exception
|
default R |
apply(T v1)
Overridden method of FunctionWithThrowable that will call applyWithThrowable, but catching any exceptions.
|
R |
applyWithThrowable(T v1)
Functional method that will throw exceptions.
|
static <T,R,E extends Throwable> |
asFunctionWithThrowable(Function<T,R> function)
Utility method to convert FunctionWithThrowable
|
static <T,R,E extends Throwable> |
castFunctionWithThrowable(FunctionWithThrowable<T,R,E> functionwiththrowable)
Utility method to mark lambdas of type FunctionWithThrowable
|
default FunctionWithThrowable<T,R,E> |
onException(BiConsumer<Throwable,Object[]> consumer) |
default FunctionWithThrowable<T,R,E> |
onException(Consumer<Throwable> consumer) |
default Function<T,R> |
thatReturnsOnCatch(R defaultReturnValue) |
default Function<T,Optional<R>> |
thatReturnsOptional() |
default Function<T,R> |
thatUnsafelyThrowsUnchecked() |
default FunctionWithThrowable<T,R,E> |
withLogging()
Will log WARNING level exceptions on logger if they occur within the interface
|
default FunctionWithThrowable<T,R,E> |
withLogging(org.slf4j.Logger logger)
Will log WARNING level exceptions on logger if they occur within the interface
|
default FunctionWithThrowable<T,R,E> |
withLogging(org.slf4j.Logger logger,
String message) |
static <T,R,E extends Throwable> FunctionWithThrowable<T,R,E> castFunctionWithThrowable(FunctionWithThrowable<T,R,E> functionwiththrowable)
T
- Generic that corresponds to the same generic on FunctionR
- Generic that corresponds to the same generic on FunctionE
- The type this interface is allowed to throwfunctionwiththrowable
- The interface instancestatic <T,R,E extends Throwable> Function<T,R> aFunctionThatUnsafelyThrowsUnchecked(FunctionWithThrowable<T,R,E> functionwiththrowable) throws E extends Throwable
T
- Generic that corresponds to the same generic on FunctionR
- Generic that corresponds to the same generic on FunctionE
- The type this interface is allowed to throwfunctionwiththrowable
- The interface instanceE
- the original Exception from functionwiththrowableE extends Throwable
static <T,R,E extends Throwable> FunctionWithThrowable<T,R,E> asFunctionWithThrowable(Function<T,R> function)
T
- Generic that corresponds to the same generic on FunctionR
- Generic that corresponds to the same generic on FunctionE
- The type this interface is allowed to throwfunction
- The interface instancedefault R apply(T v1)
R applyWithThrowable(T v1) throws E extends Throwable
default Function<T,Optional<R>> thatReturnsOptional()
default Function<T,R> thatReturnsOnCatch(R defaultReturnValue)
defaultReturnValue
- A value to return if any throwable is caught.default Function<T,R> thatUnsafelyThrowsUnchecked() throws E extends Throwable
default FunctionWithThrowable<T,R,E> withLogging(org.slf4j.Logger logger, String message)
logger
- The logger to log exceptions onmessage
- A message to use for logging exceptionsdefault FunctionWithThrowable<T,R,E> withLogging(org.slf4j.Logger logger)
logger
- The logger instance to log exceptions ondefault FunctionWithThrowable<T,R,E> withLogging()
default FunctionWithThrowable<T,R,E> onException(Consumer<Throwable> consumer)
consumer
- An exception consumer.default FunctionWithThrowable<T,R,E> onException(BiConsumer<Throwable,Object[]> consumer)
consumer
- An exception consumer.Copyright © 2017. All rights reserved.