The table below gathers the mostly used functional interfaces within Java 8:
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 |
none |
T |
get |
Supplies a value of type T |
|
Consumer |
T |
void |
accept |
Consumes a value of type T |
chain |
BiConsumer |
T, U |
void |
accept |
Consumes values of types T and U |
chain |
Function |
T |
R |
apply |
A function with argument of type T |
compose, andThen, identity |
BiFunction |
T, U |
R |
apply |
A function with arguments of types T and U |
andThen |
UnaryOperator |
T |
T |
apply |
A unary operator on the type T |
compose, andThen, identity |
BinaryOperator |
T, T |
T |
apply |
A binary operator on the type T |
andThen |
Predicate |
T |
boolean |
test |
A Boolean-valued function |
and, or, negate, isEqual |
BiPredicate |
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, p |
void |
accept |
PFunction |
p |
T |
apply |
PToQFunction |
p |
q |
applyAsQ |
ToPFunction |
T |
p |
applyAsP |
ToPBiFunction |
T, U |
p |
applyAsP |
PUnaryOperator |
p |
p |
applyAsP |
PBinaryOperator |
p, p |
p |
applyAsP |
PPredicate |
p |
boolean |
test |
No comments:
Post a Comment