generator.server.pagination.rest.rest-pagination.md.mustache Maven / Gradle / Ivy
# Rest pagination
Let's consider a very common use case to get paginated information. In `BeersApplicationService` we have:
```java
public {{baseName}}Page list({{baseName}}Pageable pagination) {
// ...
}
```
To call that and expose a result using a rest service, we can do something like that:
```java
private final BeersApplicationService beers;
// ...
ResponseEntity> list(@Validated Rest{{baseName}}Pageable pagination) {
return ResponseEntity.ok(Rest{{baseName}}Page.from(beers.list(pagination.toPageable()), RestBeer::from));
}
```
And we'll need a mapping method in `RestBeer`:
```java
static RestBeer from(Beer beer) {
// ...
}
```
© 2015 - 2025 Weber Informatics LLC | Privacy Policy