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
public final class NeverThrowsException extends RuntimeException
TheNeverThrowsException
class is an uninstantiable placeholder exception which should be used for indicating that aFunction
orAsyncFunction
never throws an exception (i.e. the function cannot fail).- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <V,E extends Exception>
Function<NeverThrowsException,V,E>neverThrown()
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>neverThrownAsync()
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 Detail
-
neverThrown
public static <V,E extends Exception> Function<NeverThrowsException,V,E> 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
public static <V,E extends Exception> AsyncFunction<NeverThrowsException,V,E> 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.
-
-