From 70c9a0d6e963b8c5839a4ecfda1462bb95e23788 Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Wed, 11 Nov 2020 18:16:03 +0100 Subject: [PATCH] DATACMNS-1837 - Add the required override to the example. The example should be a compilable unit. Original pull request: #475. --- src/main/asciidoc/repositories.adoc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/asciidoc/repositories.adoc b/src/main/asciidoc/repositories.adoc index 3ff20aaa2..a55683a5a 100644 --- a/src/main/asciidoc/repositories.adoc +++ b/src/main/asciidoc/repositories.adoc @@ -657,16 +657,23 @@ 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. +<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. ====