Streams
In software engineering, a fluent interface is an object-oriented API whose design relies extensively on method chaining. Its goal is to increase code legibility by creating a domain-specific language (DSL). (↪wiki)
In @fluentfixture, factories are small and valuable units, but they are very incapable of building complex and conditional data. Streams are factory wrappers (stream is a kind of factory) that provide a fluent interface. All methods of streams create other streams that wrap themselves. Like any factory, streams are also immutable and reusable types.
Stream instances cannot be initialized directly. Instead of this, generator functions can be used.
Decomposition Of A Stream
In the following example, a stream is built by compositions of many components.
Let's decompose the stream above to understand the stream and factory concept.
int(1, 100)
IntegerFactory
generates an integer
.add(0.5)
FunctionDecorator
adds 0.5
to the previous output
.array(10)
Iterator
Iterates to decorated factory
.sort(...)
FunctionDecorator
sorts the previous output
.join(...)
FunctionDecorator
merge the previos output
.format(...)
FormatDecorator
formats the previous output
.upperCase()
FunctionDecorator
converts to upper case the previous outout
Last updated