Dealing with instance stages by using the pipeline pattern
The pipeline pattern can make a significant contribution to improving the organization of multiple downstream operations.
Motivation
This pattern improves data processing in a series of stages by providing an initial input and passing the processed output along for use in subsequent stages. The processing elements are arranged in a continuous pipeline so that the output of one is the input of another, similar to how a physical pipe works. A pipeline pattern can provide some kind of buffering between successive members, represented by object instances. The information that flows through these pipes is often a stream of records.
Finding it in the JDK
The most obvious example of the use of the pipeline pattern is the Stream
interface and its implementations. The interface is part of the Stream API and is shipped together with the java.base
module and the java.util.stream
package.
Sample code
Let’s imagine...