Skip to content

Add the required override to the example. #475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/main/asciidoc/repositories.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -557,16 +557,22 @@ class Products implements Streamable<Product> { <2>
.map(Priced::getPrice)
.reduce(Money.of(0), MonetaryAmount::add);
}

@Override public Iterator<Product> iterator() { // <4>
return streamable.iterator();
}
}

interface ProductRepository implements Repository<Product, Long> {
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<Product>` that can be constructed by using `Products.of(…)` (factory method created with the Lombok annotation).
A standard constructor taking the `Streamable<Product>` will do as well.
<3> The wrapper type exposes an additional API, calculating new values on the `Streamable<Product>`.
<4> That wrapper type can be used as a query method return type directly. You need not return `Streamable<Product>` 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<Product>` and manually wrap it in the repository client.
====

[[repositories.collections-and-iterables.vavr]]
Expand Down