View Javadoc

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   import static javax.xml.bind.annotation.XmlAccessType.FIELD;
10  import javax.xml.bind.annotation.XmlAccessorType;
11  import javax.xml.bind.annotation.XmlElement;
12  import javax.xml.bind.annotation.XmlRootElement;
13  import javax.xml.bind.annotation.XmlTransient;
14  import java.util.List;
15  
16  @XmlRootElement
17  @XmlAccessorType(FIELD)
18  public class Players extends AbstractPagedListWrapper<Player>
19  {
20      @XmlElement(name = "player")
21      private List<Player> players;
22  
23      @XmlTransient
24      private UriBuilder uriBuilder;
25  
26      // for JAXB
27      private Players()
28      {
29          super(0, 0);
30      }
31  
32      public Players(int size, int maxItems, UriBuilder uriBuilder)
33      {
34          super(size, maxItems);
35          this.uriBuilder = uriBuilder;
36      }
37  
38      public ListWrapperCallback<Player> getPagingCallback()
39      {
40          return ListWrapperCallBacks.ofList(DataStore.getInstance().getPlayers(uriBuilder), getMaxResults());
41      }
42  
43      public List<Player> getPlayers()
44      {
45          return players;
46      }
47  }