How to do it...

In this recipe, we'll create a wrapper class to represent collections of resources with pagination information. We'll also use the JsonRootName annotation from the jackson library to make single-resource representations consistent. The following code should be added to the message service, which was introduced in a previous recipe:

  1. Create a new class called ResourceCollection. This class will be a regular POJO with fields to represent the page number, a list of items, and a URL that can be used to access the next page in a collection:
package com.packtpub.microservices.ch04.message.models;import com.fasterxml.jackson.annotation.JsonProperty;import com.fasterxml.jackson.annotation.JsonRootName;import java.util.List;@JsonRootName("result") ...

Get Microservices Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.