The following example demonstrates modelling a simple collection resource using the PaginatedCollectionResource definition and JAXB annotations:
/** * {@code BookCollectionResource} represents a collection of books. The resource holds a collection of * {@link BookResource} entries and the common fields of collection resources which support pagination. Paging may be * defined via {@link HttpHeaders#RANGE} and {@link HttpHeaders#CONTENT_RANGE} headers or via * {@link QueryParameters#OFFSET} and {@link QueryParameters#LIMIT} query parameters. */@SuppressWarnings("javadoc")@XmlRootElement(name = "books")@XmlType(name = "books") public class BookCollectionResource extends PaginatedCollectionResource { // href field is now inherited from {{BasicResource}} // offset, limit, previous, next, last first are now inherider from {{PaginatedCollectionResource}} private Collection<BookResource> entries; /** * Collection of {@link BookResource} representations that satisfy the filtering and limitation constraints given as * query parameters. In case there are no books to satisfy the constraints then this field is omitted. {@code GET} */ @XmlElement(name = "entries", required = false) public Collection<BookResource> getEntries() { return entries; } public void setEntries(Collection<BookResource> entries) { this.entries = entries; }}