Composing Consumers – Functional-Style Programming

Composing Consumers The method andThen() can be used to chain together consumers to compose compound consumers. The three consumers used earlier to resize, reverse, and print a StringBuilder can be chained together as seen here: Click here to view code image resizeSB.andThen(reverseSB)    .andThen(printSB).accept(new StringBuilder(“Banana”)); // StringBuilder: anaB The constituent consumers are executed one after the … Read moreComposing Consumers – Functional-Style Programming

Filtering Criteria Defined by Anonymous Classes – Functional-Style Programming

Filtering Criteria Defined by Anonymous Classes Example 13.3 uses anonymous classes to instantiate the criteria object, as shown at (1) and (2). The basic idea is that we can both declare and instantiate the class at the same time, where it is needed in the code, and in our case, as an argument in the … Read moreFiltering Criteria Defined by Anonymous Classes – Functional-Style Programming