< prev index next >
src/java.base/share/classes/java/util/function/Function.java
Print this page
*** 20,30 ****
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
! package java.util.function;
import java.util.Objects;
/**
* Represents a function that accepts one argument and produces a result.
--- 20,30 ----
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
! package javany.util.function;
import java.util.Objects;
/**
* Represents a function that accepts one argument and produces a result.
*** 36,46 ****
* @param <R> the type of the result of the function
*
* @since 1.8
*/
@FunctionalInterface
! public interface Function<T, R> {
/**
* Applies this function to the given argument.
*
* @param t the function argument
--- 36,46 ----
* @param <R> the type of the result of the function
*
* @since 1.8
*/
@FunctionalInterface
! public interface Function<any T, any R> {
/**
* Applies this function to the given argument.
*
* @param t the function argument
*** 61,71 ****
* function and then applies this function
* @throws NullPointerException if before is null
*
* @see #andThen(Function)
*/
! default <V> Function<V, R> compose(Function<? super V, ? extends T> before) {
Objects.requireNonNull(before);
return (V v) -> apply(before.apply(v));
}
/**
--- 61,71 ----
* function and then applies this function
* @throws NullPointerException if before is null
*
* @see #andThen(Function)
*/
! default <any V> Function<V, R> compose(Function<? super V, ? extends T> before) {
Objects.requireNonNull(before);
return (V v) -> apply(before.apply(v));
}
/**
*** 81,100 ****
* applies the {@code after} function
* @throws NullPointerException if after is null
*
* @see #compose(Function)
*/
! default <V> Function<T, V> andThen(Function<? super R, ? extends V> after) {
Objects.requireNonNull(after);
return (T t) -> after.apply(apply(t));
}
/**
* Returns a function that always returns its input argument.
*
* @param <T> the type of the input and output objects to the function
* @return a function that always returns its input argument
*/
! static <T> Function<T, T> identity() {
return t -> t;
}
}
--- 81,100 ----
* applies the {@code after} function
* @throws NullPointerException if after is null
*
* @see #compose(Function)
*/
! default <any V> Function<T, V> andThen(Function<? super R, ? extends V> after) {
Objects.requireNonNull(after);
return (T t) -> after.apply(apply(t));
}
/**
* Returns a function that always returns its input argument.
*
* @param <T> the type of the input and output objects to the function
* @return a function that always returns its input argument
*/
! static <any T> Function<T, T> identity() {
return t -> t;
}
}
< prev index next >