1 package com.atlassian.plugins.rest.sample.expansion.entity;
2
3 import com.atlassian.plugins.rest.common.expand.entity.AbstractPagedListWrapper;
4 import com.atlassian.plugins.rest.common.expand.entity.ListWrapperCallBacks;
5 import com.atlassian.plugins.rest.common.expand.entity.ListWrapperCallback;
6 import com.atlassian.plugins.rest.sample.expansion.resource.DataStore;
7
8 import javax.ws.rs.core.UriBuilder;
9
10 import static javax.xml.bind.annotation.XmlAccessType.FIELD;
11
12 import javax.xml.bind.annotation.XmlAccessorType;
13 import javax.xml.bind.annotation.XmlElement;
14 import javax.xml.bind.annotation.XmlRootElement;
15 import javax.xml.bind.annotation.XmlTransient;
16 import java.util.List;
17
18 @XmlRootElement
19 @XmlAccessorType(FIELD)
20 public class Players extends AbstractPagedListWrapper<Player> {
21 @XmlElement(name = "player")
22 private List<Player> players;
23
24 @XmlTransient
25 private UriBuilder uriBuilder;
26
27
28 private Players() {
29 super(0, 0);
30 }
31
32 public Players(int size, int maxItems, UriBuilder uriBuilder) {
33 super(size, maxItems);
34 this.uriBuilder = uriBuilder;
35 }
36
37 public ListWrapperCallback<Player> getPagingCallback() {
38 return ListWrapperCallBacks.ofList(DataStore.getInstance().getPlayers(uriBuilder), getMaxResults());
39 }
40
41 public List<Player> getPlayers() {
42 return players;
43 }
44 }