Package org.forgerock.util
Interface Function<VIN,VOUT,E extends Exception>
- Type Parameters:
VIN- The type of the function parameter, orVoidif the function does not expect a parameter.VOUT- The type of the function result, orVoidif the function does not return anything (i.e. it only has side-effects).E- The type of the exception thrown by the function, orNeverThrowsExceptionif no exception is thrown by the function.
- All Known Subinterfaces:
AsyncFunction<VIN,VOUT, E>
- All Known Implementing Classes:
CloseSilentlyFunction,JsonValueTraverseFunction
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
-
Method Details
-
apply
Applies this function to the input parametervalueand 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.
-