Package org.forgerock.util.promise
Class NeverThrowsException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.forgerock.util.promise.NeverThrowsException
- All Implemented Interfaces:
Serializable
The
NeverThrowsException
class is an uninstantiable placeholder
exception which should be used for indicating that a Function
or
AsyncFunction
never throws an exception (i.e. the function cannot
fail).- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V,
E extends Exception>
Function<NeverThrowsException,V, E> Utility method returning an empty function, whose goal is to ease the transformation of aPromise
type.static <V,
E extends Exception>
AsyncFunction<NeverThrowsException,V, E> Utility method returning an empty function, whose goal is to ease the transformation of aPromise
type.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Method Details
-
neverThrown
Utility method returning an empty function, whose goal is to ease the transformation of aPromise
type. Its main usage will be as the second argument inPromise.then(Function, Function)
. The implementation of this function is just to throw anIllegalStateException
: but it will never be invoked as anException
of typeNeverThrowsException
will never be thrown.- Type Parameters:
V
- The expected type of that functionE
- The newException
that can be thrown by this function.- Returns:
- a function that will throw an
IllegalStateException
: but it will never be invoked as anException
of typeNeverThrowsException
will never be thrown.
-
neverThrownAsync
Utility method returning an empty function, whose goal is to ease the transformation of aPromise
type. Its main usage will be as the second argument inPromise.thenAsync(AsyncFunction, AsyncFunction)
. The implementation of this function is just to return a promise of anIllegalStateException
: but it will never be invoked as anException
of typeNeverThrowsException
will never be thrown.- Type Parameters:
V
- The expected type of that functionE
- The newException
that can be thrown by this function.- Returns:
- an async function that will throw an
IllegalStateException
: but it will never be invoked as anException
of typeNeverThrowsException
will never be thrown.
-