concept functional interface in category software development

appears as: Functional interfaces, functional interface, functional interface
Seriously Good Software: Code that works, survives, and wins

This is an excerpt from Manning's book Seriously Good Software: Code that works, survives, and wins.

Notice the close similarity between this imaginary collector and the Attribute interface introduced earlier for abstracting the water level value of containers. However, the actual Collector interface introduces one more level of indirection by having each method return an object that performs the corresponding function. This is in line with the rest of the stream framework and with the functional programming style by which it’s inspired. The return types for all four methods are functional interfaces, that is, interfaces that each have a single abstract method. Table 9.2 outlines the characteristics of these four interfaces.

Table 9.2. Functional interfaces mutable collectors use. They’re among the more than 40 functional interfaces in the java.util.function package. (view table figure)

Interface

Type of abstract method

Role

Supplier<S> void → S Provides the initial summary
BiConsumer<S,V> (S, V) → void Updates a summary with a value
BinaryOperator<S> (S, S) → S Merges two summaries
Function<S,R> S → R Converts a summary into a result
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest