Package org.forgerock.util
Interface Function<VIN,VOUT,E extends Exception>
- Type Parameters:
VIN
- The type of the function parameter, orVoid
if the function does not expect a parameter.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 Known Implementing Classes:
CloseSilentlyFunction
,HsmKeyStoreLoader
,JsonDecryptFunction
,JsonEncryptFunction
,JsonValueTraverseFunction
,TranslateJsonSchema
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A synchronous function which returns a result immediately.
Exception handling: implementations which do not throw any exceptions
should declare that they throw an exception of type
NeverThrowsException
.
Example usage:
public class IsPossiblePrime implements Function<String, Boolean, IllegalArgumentException> { public Boolean apply(String value) throws IllegalArgumentException { // Parse the parameter now and potentially immediately throw an // exception. final BigInteger possiblePrime = new BigInteger(value); // Determine if the parameter is a prime number. return possiblePrime.isProbablePrime(1000); } }
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturns a composed function that first applies this function to its input, and then applies theafter
function to the result.Applies this function to the input parametervalue
and returns the result.Returns a composed function that first applies thebefore
function to its input, and then applies this function to the result.identity()
Returns an identity function that returns the input as output.
-
Method Details
-
apply
Applies this function to the input parametervalue
and returns the result.- Parameters:
value
- The input parameter.- Returns:
- The result of applying this function to
value
. - Throws:
E
- If this function cannot be applied tovalue
.
-
compose
Returns a composed function that first applies thebefore
function to its input, and then applies this function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the composed function.- Type Parameters:
V
- the type of input to thebefore
function, and to the composed function- Parameters:
before
- the function to apply before this function is applied- Returns:
- a composed function that first applies the
before
function and then applies this function - Throws:
NullPointerException
- if before is nullE extends Exception
- See Also:
-
andThen
Returns a composed function that first applies this function to its input, and then applies theafter
function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the composed function.- Type Parameters:
V
- the type of output of theafter
function, and of the composed function- Parameters:
after
- the function to apply after this function is applied- Returns:
- a composed function that first applies this function and then
applies the
after
function - Throws:
NullPointerException
- if after is null- See Also:
-
identity
Returns an identity function that returns the input as output.- Type Parameters:
V
- the input/output typeE
- The type of the exception thrown by the function, orNeverThrowsException
if no exception is thrown by the function.- Returns:
- an identity function that will return a result promise of the input.
-