1 package com.atlassian.plugins.rest.test;
2
3 import com.atlassian.plugins.rest.common.expand.Expandable;
4 import com.atlassian.plugins.rest.common.expand.entity.ListWrapperCallBacks;
5 import com.google.common.collect.ImmutableList;
6
7 import javax.ws.rs.core.UriInfo;
8 import javax.xml.bind.annotation.XmlAccessType;
9 import javax.xml.bind.annotation.XmlAccessorType;
10 import javax.xml.bind.annotation.XmlAttribute;
11 import javax.xml.bind.annotation.XmlElement;
12 import javax.xml.bind.annotation.XmlRootElement;
13 import java.util.Collections;
14 import java.util.List;
15
16 @XmlRootElement
17 @XmlAccessorType(XmlAccessType.FIELD)
18 public class Project {
19 @XmlAttribute
20 private String expand;
21
22 @XmlAttribute
23 private final String name;
24
25 @XmlElement
26 private final String description;
27
28 @XmlElement
29 @Expandable
30 private ProjectInformation information;
31
32 @XmlElement
33 @Expandable
34 private Developers developers;
35
36
37 private Project() {
38 this.name = null;
39 this.description = null;
40 }
41
42 public Project(String name, String description) {
43 this.name = name;
44 this.description = description;
45 }
46
47 public String getName() {
48 return name;
49 }
50
51 public String getDescription() {
52 return description;
53 }
54
55 public ProjectInformation getInformation() {
56 return information;
57 }
58
59 public void setInformation(ProjectInformation information) {
60 this.information = information;
61 }
62
63 public List<Developer> getDevelopers() {
64 return developers.getDevelopers() != null ? ImmutableList.copyOf(developers.getDevelopers()) : Collections.<Developer>emptyList();
65 }
66
67 public void setDevelopers(Developers developers) {
68 this.developers = developers;
69 }
70
71 public Project build(UriInfo uriInfo) {
72 setInformation(ProjectInformation.getInformation(uriInfo));
73
74 final List<Developer> developerList = DeveloperStore.getDevelopers(uriInfo);
75 setDevelopers(new Developers(developerList.size(), ListWrapperCallBacks.ofList(developerList)));
76 return this;
77 }
78 }