(source: Java SE 8 for the Really Impatient: Programming with Lambdas - 3.3. Choosing a Functional Interface)
Common Functional Interfaces
|
Functional Interface |
Parameter Types |
Return Type |
Abstract Method Name |
Description |
Other Methods |
|
Runnable
|
none |
void
|
run
|
Runs an action without arguments or return value |
|
|
Supplier<T>
|
none |
T
|
get
|
Supplies a value of type T |
|
|
Consumer<T>
|
T
|
void
|
accept
|
Consumes a value of type T |
chain
|
|
BiConsumer<T, U>
|
T, U
|
void
|
accept
|
Consumes values of types T and U |
chain
|
|
Function<T, R>
|
T
|
R
|
apply
|
A function with argument of type T |
compose, andThen, identity
|
|
BiFunction<T, U, R>
|
T, U
|
R
|
apply
|
A function with arguments of types T and U |
andThen
|
|
UnaryOperator<T>
|
T
|
T
|
apply
|
A unary operator on the type T |
compose, andThen, identity
|
|
BinaryOperator<T>
|
T, T
|
T
|
apply
|
A binary operator on the type T |
andThen
|
|
Predicate<T>
|
T
|
boolean
|
test
|
A Boolean-valued function |
and, or, negate, isEqual
|
|
BiPredicate<T, U>
|
T, U
|
boolean
|
test
|
A Boolean-valued function with two arguments |
and, or, negate
|
Functional Interfaces for Primitive Types
p, q is int, long, double; P, Q is Int, Long, Double
|
Functional Interface |
Parameter Types |
Return Type |
Abstract Method Name |
|
BooleanSupplier
|
none |
boolean
|
getAsBoolean
|
|
PSupplier |
none |
p |
getAsP
|
|
PConsumer |
p |
void
|
accept
|
|
ObjPConsumer<T>
|
T, p
|
void
|
accept
|
|
PFunction<T> |
p |
T
|
apply
|
|
PToQFunction |
p |
q |
applyAsQ
|
|
ToPFunction<T>
|
T
|
p |
applyAsP
|
|
ToPBiFunction<T, U>
|
T, U
|
p |
applyAsP
|
|
PUnaryOperator |
p |
p |
applyAsP
|
|
PBinaryOperator |
p, p |
p |
applyAsP
|
|
PPredicate |
p |
boolean
|
test
|