Package org.forgerock.util
Class CloseSilentlyFunction<VIN extends Closeable,VOUT,E extends Exception>
java.lang.Object
org.forgerock.util.CloseSilentlyFunction<VIN,VOUT,E>
- Type Parameters:
VIN
- The type of the function input-parameter, which implementsCloseable
.VOUT
- The type of the function result, orVoid
if the function does not return anything (i.e. it only has side-effects).E
- The type of the exception thrown by the function, orNeverThrowsException
if no exception is thrown by the function.
- All Implemented Interfaces:
Function<VIN,
VOUT, E>
public class CloseSilentlyFunction<VIN extends Closeable,VOUT,E extends Exception>
extends Object
implements Function<VIN,VOUT,E>
Function
that silently closes an input-parameter after a delegate-function's Function.apply(Object)
is invoked. The static closeSilently(Function)
method is provided for convenience.-
Constructor Summary
ConstructorDescriptionCloseSilentlyFunction
(Function<VIN, VOUT, E> delegate) Creates a newCloseSilentlyFunction
instance. -
Method Summary
Modifier and TypeMethodDescriptionInvokes the delegate function'sFunction.apply(Object)
with the input parametervalue
, closes it, and returns the result.closeSilently
(Function<IN, OUT, EX> delegate) Wraps a delegate function in aCloseSilentlyFunction
.
-
Constructor Details
-
CloseSilentlyFunction
Creates a newCloseSilentlyFunction
instance.- Parameters:
delegate
- Delegate function.
-
-
Method Details
-
apply
Invokes the delegate function'sFunction.apply(Object)
with the input parametervalue
, closes it, and returns the result. -
closeSilently
public static <IN extends Closeable,OUT, Function<IN,EX extends Exception> OUT, closeSilentlyEX> (Function<IN, OUT, EX> delegate) Wraps a delegate function in aCloseSilentlyFunction
.- Type Parameters:
IN
- The type of the function input-parameter, which implementsCloseable
.OUT
- The type of the function result, orVoid
if the function does not return anything (i.e. it only has side-effects).EX
- The type of the exception thrown by the function, orNeverThrowsException
if no exception is thrown by the function.- Parameters:
delegate
- Delegate function.- Returns:
- New
CloseSilentlyFunction
instance.
-