public final class Converter extends Object
XFunction)
into more common constructs (e.g. Function) that will wrap such exceptions in unchecked exceptions.Conversion| Modifier and Type | Method and Description |
|---|---|
static Function<Throwable,RuntimeException> |
altWrapping(Function<String,RuntimeException> wrapping)
Returns an alternative wrapping method for
using(Function) that uses the
message of the original Exception to create the wrapping
RuntimeException. |
<T,U> BiConsumer<T,U> |
biConsumer(XBiConsumer<T,U,?> xBiConsumer)
Wraps an
XBiConsumer that may throw a checked exception as BiConsumer that,
when executed, wraps any occurring checked exception as specific unchecked exception. |
<T,U,R> BiFunction<T,U,R> |
biFunction(XBiFunction<T,U,R,?> xBiFunction)
Wraps an
XBiFunction that may throw a checked exception as BiFunction that,
when executed, wraps any occurring checked exception as a specific unchecked exception. |
<T,U> BiPredicate<T,U> |
biPredicate(XBiPredicate<T,U,?> xBiPredicate)
Wraps an
XBiPredicate that may throw a checked exception as BiPredicate that,
when executed, wraps any occurring checked exception as a specific unchecked exception. |
<T> Consumer<T> |
consumer(XConsumer<T,?> xConsumer)
|
<T,R> Function<T,R> |
function(XFunction<T,R,?> xFunction)
|
<T> Predicate<T> |
predicate(XPredicate<T,?> xPredicate)
Wraps an
XPredicate that may throw a checked exception as Predicate that,
when executed, wraps any occurring checked exception as specific unchecked exception. |
Runnable |
runnable(XRunnable<?> xRunnable)
|
static Function<Throwable,RuntimeException> |
stdWrapping(BiFunction<String,Throwable,RuntimeException> wrapping)
Returns a standard wrapping method for
using(Function) that uses the
message of the original Exception to create the wrapping
RuntimeException. |
<R> Supplier<R> |
supplier(XSupplier<R,?> xSupplier)
|
static Converter |
using(Function<Throwable,RuntimeException> wrapping)
Returns a new instance using a given wrapping method.
|
public static Converter using(Function<Throwable,RuntimeException> wrapping)
stdWrapping(BiFunction),
altWrapping(Function)public static Function<Throwable,RuntimeException> stdWrapping(BiFunction<String,Throwable,RuntimeException> wrapping)
using(Function) that uses the
message of the original Exception to create the wrapping
RuntimeException.
This is mainly intended to view a typical standard constructor of a RuntimeException that requires two
parameters (message text and causing exception, e.g.
WrappedException.WrappedException(String, Throwable)) as a Function in order to use it with
using(Function).
The resulting function uses the message text of the causing exception unchanged as the message text of its
resulting RuntimeException.
Example:
import static de.team33.libs.exceptional.v4.functional.Converter.stdWrapping;
import static de.team33.libs.exceptional.v4.functional.Converter.using;
public class MyClass {
private static final FunctionalConverter CONVERTER = using(stdWrapping(WrappedException::new));
// ...
}
public static Function<Throwable,RuntimeException> altWrapping(Function<String,RuntimeException> wrapping)
using(Function) that uses the
message of the original Exception to create the wrapping
RuntimeException.
This is mainly intended to view a typical standard constructor of a RuntimeException that requires a
single string parameter (the detail message) as a Function in order to use it with
using(Function).
The resulting function uses the message text of the causing exception unchanged as the message text of its
resulting RuntimeException and then initializes the causing exception as its cause.
Example:
import static de.team33.libs.exceptional.v4.functional.Converter.altWrapping;
import static de.team33.libs.exceptional.v4.functional.Converter.using;
public class MyConversion {
private static final FunctionalConverter CONVERTER = using(altWrapping(MyException::new));
// ...
public static class MyException extends RuntimeException {
public MyException(final String message) {
super(message);
}
}
}
public final <T,U> BiConsumer<T,U> biConsumer(XBiConsumer<T,U,?> xBiConsumer)
XBiConsumer that may throw a checked exception as BiConsumer that,
when executed, wraps any occurring checked exception as specific unchecked exception.public final <T> Predicate<T> predicate(XPredicate<T,?> xPredicate)
XPredicate that may throw a checked exception as Predicate that,
when executed, wraps any occurring checked exception as specific unchecked exception.public final <T,U> BiPredicate<T,U> biPredicate(XBiPredicate<T,U,?> xBiPredicate)
XBiPredicate that may throw a checked exception as BiPredicate that,
when executed, wraps any occurring checked exception as a specific unchecked exception.public final <T,U,R> BiFunction<T,U,R> biFunction(XBiFunction<T,U,R,?> xBiFunction)
XBiFunction that may throw a checked exception as BiFunction that,
when executed, wraps any occurring checked exception as a specific unchecked exception.Copyright © 2021. All rights reserved.