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>
657
657
.map(Priced::getPrice)
658
658
.reduce(Money.of(0), MonetaryAmount::add);
659
659
}
660
+
661
+
662
+ @Override public Iterator<Product> iterator() { // <4>
663
+ return streamable.iterator();
664
+ }
660
665
}
661
666
662
667
interface ProductRepository implements Repository<Product, Long> {
663
- Products findAllByDescriptionContaining(String text); <4 >
668
+ Products findAllByDescriptionContaining(String text); <5 >
664
669
}
665
670
----
666
671
<1> A `Product` entity that exposes API to access the product's price.
667
672
<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.
668
674
<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.
670
677
You need not return `Streamable<Product>` and manually wrap it in the repository client.
671
678
====
672
679
You can’t perform that action at this time.
0 commit comments