liveBook · Manning

Intermediate operation

As explained in The Art of Code

An intermediate operation is a pipeline operation that describes a further transformation and normally defers its execution until a terminal operation.

An intermediate operation adds a transformation to a functional pipeline without processing data immediately. It keeps intent visible and defers evaluation until a terminal operation triggers execution. section 6.3.1 section 6.5

In a Java stream pipeline, intermediate operations commonly:

  • Filter elements with a predicate, retaining only values that satisfy a condition. section 6.3.1
  • Map elements into another representation, such as converting books into author names. section 6.3.1
  • Chain multiple transformations while postponing processing until operations such as toList, collect, or count execute the pipeline. section 6.5

Filter, then map

A readable pipeline selects books published within the last year and extracts their authors: books.stream().filter(book -> book.publishedDate().isAfter(LocalDate.now().minusYears(1))).map(Book::author).toList(). The filter and map operations describe the work; toList performs it and materializes the result. section 6.3.1 section 6.5

List<String> authorNames = books.stream()     #1
   .filter(book -> book.publishedDate()         #2
   .isAfter(LocalDate.now().minusYears(1)))     #2
   .map(Book::author)                           #2
   .toList();     #3

The annotated listing separates stream creation, intermediate operations, and the terminal operation in one complete Java example. section 6.3.1

How The Art of Code covers it

How deep it goes
Explains pipeline stages, laziness, chaining, and consumption without descending into stream implementation internals.
Examples
Uses book collections, recent-publication filtering, author mapping, annotated stream listings, and imperative-to-pipeline comparisons.
What it assumes
Assumes familiarity with Java collections and objects while introducing predicates, functions, lambdas, and pipeline stages.
What you can do after
Apply via the Java Stream API to compose lazy filter, map, and flatMap transformations before materializing results.
How it connects
Connects intermediate operations to pipelines, lazy evaluation, terminal operations, lambdas, method references, and functional interfaces.

Also explained in

Compare how 3 books explain intermediate operation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Art of Code. The section links point to the parts of the book it draws on.