Package com.globalmentor.io.function
Interface IOFunction<T,R>
-
- Type Parameters:
T
- the type of the input to the functionR
- the type of the result of the function
- All Known Subinterfaces:
IOUnaryOperator<T>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface IOFunction<T,R>
Represents a function that accepts one argument and produces a result.This interface is similar to
Function
except that it is allowed to throw anIOException
.- Author:
- Magno N A Cruz
- See Also:
Function
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <V> IOFunction<T,V>
andThen(IOFunction<? super R,? extends V> after)
This method is the same asFunction.andThen(Function)
, but with a support forIOException
.R
apply(T t)
This method is the same asFunction.apply(Object)
, but with a support forIOException
.default <V> IOFunction<V,R>
compose(IOFunction<? super V,? extends T> before)
This method is the same asFunction.compose(Function)
, but with a support forIOException
.static <T> IOFunction<T,T>
identity()
Returns a function that always returns its input argument.
-
-
-
Method Detail
-
apply
R apply(T t) throws java.io.IOException
This method is the same as
Function.apply(Object)
, but with a support forIOException
.- Parameters:
t
- The function argument.- Returns:
- The function result.
- Throws:
java.io.IOException
- if there is an I/O error performing the operation.
-
compose
default <V> IOFunction<V,R> compose(@Nonnull IOFunction<? super V,? extends T> before) throws java.io.IOException
This method is the same as
Function.compose(Function)
, but with a support forIOException
.- 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:
java.io.IOException
- if there is an I/O error performing the operation.- See Also:
andThen(IOFunction)
-
andThen
default <V> IOFunction<T,V> andThen(@Nonnull IOFunction<? super R,? extends V> after) throws java.io.IOException
This method is the same as
Function.andThen(Function)
, but with a support forIOException
.- 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:
java.io.IOException
- if there is an I/O error performing the operation.- See Also:
compose(IOFunction)
-
identity
static <T> IOFunction<T,T> identity() throws java.io.IOException
Returns a function that always returns its input argument.- Type Parameters:
T
- The type of the input and output objects to the function.- Returns:
- A function that always returns its input argument.
- Throws:
java.io.IOException
- if there is an I/O error performing the operation.
-
-