diff --git a/src/main/asciidoc/repositories.adoc b/src/main/asciidoc/repositories.adoc index b95c5c199f..c9c09b50ca 100644 --- a/src/main/asciidoc/repositories.adoc +++ b/src/main/asciidoc/repositories.adoc @@ -557,16 +557,22 @@ class Products implements Streamable { <2> .map(Priced::getPrice) .reduce(Money.of(0), MonetaryAmount::add); } + + @Override public Iterator iterator() { // <4> + return streamable.iterator(); + } } interface ProductRepository implements Repository { - Products findAllByDescriptionContaining(String text); <4> + Products findAllByDescriptionContaining(String text); <5> } ---- <1> A `Product` entity that exposes API to access the product's price. <2> A wrapper type for a `Streamable` that can be constructed by using `Products.of(…)` (factory method created with the Lombok annotation). + A standard constructor taking the `Streamable` will do as well. <3> The wrapper type exposes an additional API, calculating new values on the `Streamable`. -<4> That wrapper type can be used as a query method return type directly. You need not return `Streamable` and manually wrap it in the repository client. +<4> Implement the `Streamable` interface and delegate to the actual result. +<5> That wrapper type can be used as a query method return type directly. You need not return `Streamable` and manually wrap it in the repository client. ==== [[repositories.collections-and-iterables.vavr]]