View Javadoc

1   package com.atlassian.plugins.rest.doclet.generators.schema.beans.permissionscheme;
2   
3   import com.atlassian.plugins.rest.doclet.generators.schema.beans.issue.UserJsonBean;
4   import com.atlassian.rest.annotation.RestProperty;
5   import com.fasterxml.jackson.annotation.JsonProperty;
6   import com.google.common.base.Objects;
7   
8   public final class PermissionHolderBean
9   {
10      public static PermissionHolderBean holderBean(String type, String parameter)
11      {
12          return new PermissionHolderBean(type, parameter, null, null, null, null);
13      }
14  
15      @JsonProperty (required = true)
16      private String type;
17      @JsonProperty (required = true)
18      private String parameter;
19  
20      @JsonProperty
21      @RestProperty (scope = RestProperty.Scope.RESPONSE)
22      private UserJsonBean user;
23      @JsonProperty
24      @RestProperty (scope = RestProperty.Scope.RESPONSE)
25      private GroupJsonBean group;
26      @JsonProperty
27      @RestProperty (scope = RestProperty.Scope.RESPONSE)
28      private FieldBean field;
29      @JsonProperty
30      @RestProperty (scope = RestProperty.Scope.RESPONSE)
31      private ProjectRoleBean projectRole;
32  
33      private boolean isInput = false;
34  
35      @Deprecated
36      public PermissionHolderBean() {}
37  
38      private PermissionHolderBean(String type, String parameter, UserJsonBean user, GroupJsonBean group, FieldBean field, ProjectRoleBean projectRole)
39      {
40          this.type = type;
41          this.parameter = parameter;
42          this.user = user;
43          this.group = group;
44          this.field = field;
45          this.projectRole = projectRole;
46      }
47  
48      @JsonProperty
49      public String getExpand()
50      {
51          return isInput ? null : "user,group,field,projectRole";
52      }
53  
54      public PermissionHolderBean input()
55      {
56          this.isInput = true;
57          return this;
58      }
59  
60      public String getType()
61      {
62          return type;
63      }
64  
65      public void setType(String type)
66      {
67          this.type = type;
68      }
69  
70      public String getParameter()
71      {
72          return parameter;
73      }
74  
75      public void setParameter(String parameter)
76      {
77          this.parameter = parameter;
78      }
79  
80      public UserJsonBean getUser()
81      {
82          return user;
83      }
84  
85      public void setUser(UserJsonBean user)
86      {
87          this.user = user;
88      }
89  
90      public GroupJsonBean getGroup()
91      {
92          return group;
93      }
94  
95      public void setGroup(GroupJsonBean group)
96      {
97          this.group = group;
98      }
99  
100     public FieldBean getField()
101     {
102         return field;
103     }
104 
105     public void setField(FieldBean field)
106     {
107         this.field = field;
108     }
109 
110     public ProjectRoleBean getProjectRole()
111     {
112         return projectRole;
113     }
114 
115     public void setProjectRole(ProjectRoleBean projectRole)
116     {
117         this.projectRole = projectRole;
118     }
119 
120     public static Builder builder()
121     {
122         return new Builder();
123     }
124 
125     public static Builder builder(PermissionHolderBean data)
126     {
127         return new Builder(data);
128     }
129 
130     @Override
131     public boolean equals(Object o)
132     {
133         if (this == o) { return true; }
134         if (o == null || getClass() != o.getClass()) { return false; }
135 
136         PermissionHolderBean that = (PermissionHolderBean) o;
137 
138         return Objects.equal(this.type, that.type) &&
139                 Objects.equal(this.parameter, that.parameter) &&
140                 Objects.equal(this.user, that.user) &&
141                 Objects.equal(this.group, that.group) &&
142                 Objects.equal(this.field, that.field) &&
143                 Objects.equal(this.projectRole, that.projectRole);
144     }
145 
146     @Override
147     public int hashCode()
148     {
149         return Objects.hashCode(type, parameter, user, group, field, projectRole);
150     }
151 
152     @Override
153     public String toString()
154     {
155         return Objects.toStringHelper(this)
156                 .add("type", type)
157                 .add("parameter", parameter)
158                 .add("user", user)
159                 .add("group", group)
160                 .add("field", field)
161                 .add("projectRole", projectRole)
162                 .toString();
163     }
164 
165     public static final class Builder
166     {
167 
168         private String type;
169         private String parameter;
170         private UserJsonBean user;
171         private GroupJsonBean group;
172         private FieldBean field;
173         private ProjectRoleBean projectRole;
174 
175         private Builder() {}
176 
177         private Builder(PermissionHolderBean initialData)
178         {
179 
180             this.type = initialData.type;
181             this.parameter = initialData.parameter;
182             this.user = initialData.user;
183             this.group = initialData.group;
184             this.field = initialData.field;
185             this.projectRole = initialData.projectRole;
186         }
187 
188         public Builder setType(String type)
189         {
190             this.type = type;
191             return this;
192         }
193 
194         public Builder setParameter(String parameter)
195         {
196             this.parameter = parameter;
197             return this;
198         }
199 
200         public Builder setUser(UserJsonBean user)
201         {
202             this.user = user;
203             return this;
204         }
205 
206         public Builder setGroup(GroupJsonBean group)
207         {
208             this.group = group;
209             return this;
210         }
211 
212         public Builder setField(FieldBean field)
213         {
214             this.field = field;
215             return this;
216         }
217 
218         public Builder setProjectRole(ProjectRoleBean projectRole)
219         {
220             this.projectRole = projectRole;
221             return this;
222         }
223 
224         public PermissionHolderBean build()
225         {
226             return new PermissionHolderBean(type, parameter, user, group, field, projectRole);
227         }
228     }
229 }