R - return typeE - exception typeP - parameter type@FunctionalInterface
public interface FragileFunction1<R,E extends java.lang.Exception,P>
| Modifier and Type | Method and Description |
|---|---|
R |
apply(P arg)
Run the function.
|
default <Any> FragileFunction2<R,E,Any,P> |
asFunction2WithAny1()
Return a view of this function which accepts an additional but ignored first parameter.
|
default <Any> FragileFunction2<R,E,P,Any> |
asFunction2WithAny2()
Return a view of this function which accepts an additional but ignored second parameter.
|
default Function1<R,P> |
nonFragile()
Convert this to a non-fragile function which does not throw a checked exception.
|
default Function1<R,P> |
nonFragile(R fallback)
Convert this to a non-fragile function which does not throw a checked exception.
|
default Function1<R,P> |
nonFragileX(java.util.function.BiFunction<? super E,? super P,? extends R> exceptionHandler)
Convert this to a non-fragile function which does not throw a checked exception.
|
R apply(P arg) throws E extends java.lang.Exception
arg - function argumentE - typed exceptionE extends java.lang.Exception@NotNull default <Any> FragileFunction2<R,E,Any,P> asFunction2WithAny1()
This is sometimes useful when another functional signature is required.
FragileFunction1<Float, IOException, Double> foo = ...;
FragileFunction2<Float, IOException, Integer, Double> bar = foo.asFunction2WithAny1();
FragileFunction2<Float, IOException, String, Double> baz = foo.asFunction2WithAny1();
Any - parameter type of returned procedure@NotNull default <Any> FragileFunction2<R,E,P,Any> asFunction2WithAny2()
This is sometimes useful when another functional signature is required.
FragileFunction1<Float, IOException, Double> foo = v -> ...;
FragileFunction2<Float, IOException, Double, Integer> bar = foo.asFunction2WithAny2();
FragileFunction2<Float, IOException, Double, String> baz = foo.asFunction2WithAny2();
Any - parameter type of returned procedure@NotNull default Function1<R,P> nonFragile()
WrappedFragileException for any
checked exception thrown during apply(Object).Function1.nonFragile(FragileFunction1)@NotNull default Function1<R,P> nonFragile(R fallback)
fallback value.
Please note that in this case the exception is completely lost!fallback - fallback valueFunction1.nonFragile(FragileFunction1, Object)@NotNull default Function1<R,P> nonFragileX(@NotNull java.util.function.BiFunction<? super E,? super P,? extends R> exceptionHandler)
exceptionHandler - handler which can handle the exception how it sees fit.
E.g. throw an unchecked exception (compare nonFragile(),
return a fallback (compare nonFragile(Object)),
or do the latter but also log or collect the exceptionFunction1.nonFragileX(FragileFunction1, BiFunction)