// If the size returned is equal then assume there is a next
if (customerEntities.size() == size)
{
int next = start + size;
URI nextUri = builder.clone().build(next, size);
Link nextLink = Link.fromUri(nextUri).rel("next").type("application/xml").build();
links.add(nextLink);
}
// previous link
if (start > 0)
{
int previous = start - size;
if (previous < 0) previous = 0;
URI previousUri = builder.clone().build(previous, size);
Link previousLink = Link.fromUri(previousUri).rel("previous").type("application/xml").build();
links.add(previousLink);
}
Customers customers = new Customers();
customers.setCustomers(list);
customers.setLinks(links);