Closely resembling the guava function, the java.util.function.Function<T,R> interface contains the method R apply(T t) when applied determines an output value based on an input value. A common usecase is when converting a list to map or when you want to convert or transform from one object to another. Since this is a functional interface it can be used as the assignment target for a lambda expression or method reference.
In the example below, we will map between a Person object and a Job object.
Map a list of objects
The Stream.map will apply the given function to all the elements in the stream. In this case, for every person object in person list, it will call the mapPersonToJob returning a Job object. We will then call the Stream.collect to convert the stream to a list.
Map object to object
The function.apply method will apply this function to a given arguement. In this case, the function.apply will convert the Person object to a Job object.