Functional Interfaces Cheat Sheet (package: java.util.
function)
Provide target types for lambda expressions and method references.
Primitive Type Prefixes
For: Predicate, Function, Consumer, UnaryOperator and BinaryOperator
Interfaces Arguments Return
When accepts primitive arguments (int, double, long) the interface is prefixed with Int,
Predicate<T> T Double, Long, e.g., LongConsumer, IntFunction, DoubleBinaryOperator.
boolean
BiPredicate<T, U> T, U
For: Supplier
Function<T, R> T
R The only interface that returns boolean primitive, apart from predicate, is
BiFunction<T, U, R> T, U BooleanSupplier.
Supplier<T> − T
For BiConsumer
Consumer<T> T Variants that accept an object and a primitive: ObjDoubleConsumer, ObjIntConsumer,
− ObjLongConsumer.
BiConsumer<T, U> T, U
For: Function and BiFunction
Special Interfaces Arguments Return When returns a primitive (int, double, long) it is prefixed with ToInt, ToDouble, ToLong,
e.g., ToIntFunction, ToDoubleBiFunction.
UnaryOperator<T> T
T
BinaryOperator<T> T, T For: Function
When accepts a primitive and returns another primitive, both prefixes are joined,
e.g., IntToDoubleFunction, LongToIntFunction.
www.theagilecrafter.com @AgileCrafter