File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -657,16 +657,23 @@ class Products implements Streamable<Product> { <2>
657657 .map(Priced::getPrice)
658658 .reduce(Money.of(0), MonetaryAmount::add);
659659 }
660+
661+
662+ @Override public Iterator<Product> iterator() { // <4>
663+ return streamable.iterator();
664+ }
660665}
661666
662667interface ProductRepository implements Repository<Product, Long> {
663- Products findAllByDescriptionContaining(String text); <4 >
668+ Products findAllByDescriptionContaining(String text); <5 >
664669}
665670----
666671<1> A `Product` entity that exposes API to access the product's price.
667672<2> A wrapper type for a `Streamable<Product>` that can be constructed by using `Products.of(…)` (factory method created with the Lombok annotation).
673+ A standard constructor taking the `Streamable<Product>` will do as well.
668674<3> The wrapper type exposes an additional API, calculating new values on the `Streamable<Product>`.
669- <4> That wrapper type can be used as a query method return type directly.
675+ <4> Implement the `Streamable` interface and delegate to the actual result.
676+ <5> That wrapper type can be used as a query method return type directly.
670677You need not return `Streamable<Product>` and manually wrap it in the repository client.
671678====
672679
You can’t perform that action at this time.
0 commit comments