Java Lambda 기본 함수형 인터페이스 java.util.function 패키지에 정의되어 있음.
-
- Functions
public interface Function<T, R> { R apply(T t); }
- Functions
-
- Suppliers
public interface Supplier<T> { T get(); }
- Consumers
public interface Consumer<T> { void accept(T t); }
- Predicates
public interface Predicate<T> { boolean test(T t); }
- Operators
public interface UnaryOperator<T> extends Function<T, T> { static <T> UnaryOperator<T> identity() { return t -> t; } }
public interface BinaryOperator<T> extends BiFunction<T,T,T> { public static <T> BinaryOperator<T> minBy(Comparator<? super T> comparator) { Objects.requireNonNull(comparator); return (a, b) -> comparator.compare(a, b) <= 0 ? a : b; } public static <T> BinaryOperator<T> maxBy(Comparator<? super T> comparator) { Objects.requireNonNull(comparator); return (a, b) -> comparator.compare(a, b) >= 0 ? a : b; } }
- Suppliers