(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 |
getAs P
|
PConsumer |
p |
void
|
accept
|
Obj PConsumer<T>
|
T , p
|
void
|
accept
|
PFunction<T> |
p |
T
|
apply
|
PTo QFunction |
p |
q |
applyAs Q
|
To PFunction<T>
|
T
|
p |
applyAs P
|
To PBiFunction<T, U>
|
T , U
|
p |
applyAs P
|
PUnaryOperator |
p |
p |
applyAs P
|
PBinaryOperator |
p, p |
p |
applyAs P
|
PPredicate |
p |
boolean
|
test
|