Reduce number of parameters
[portal.git] / ecomp-portal-BE-common / src / main / java / org / onap / portalapp / portal / transport / CentralV2Role.java
1 /*-
2  * ============LICENSE_START==========================================
3  * ONAP Portal
4  * ===================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ===================================================================
7  *
8  * Unless otherwise specified, all software contained herein is licensed
9  * under the Apache License, Version 2.0 (the "License");
10  * you may not use this software except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *             http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  * Unless otherwise specified, all documentation contained herein is licensed
22  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23  * you may not use this documentation except in compliance with the License.
24  * You may obtain a copy of the License at
25  *
26  *             https://creativecommons.org/licenses/by/4.0/
27  *
28  * Unless required by applicable law or agreed to in writing, documentation
29  * distributed under the License is distributed on an "AS IS" BASIS,
30  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31  * See the License for the specific language governing permissions and
32  * limitations under the License.
33  *
34  * ============LICENSE_END============================================
35  *
36  * 
37  */
38 package org.onap.portalapp.portal.transport;
39
40 import java.io.Serializable;
41 import java.util.Date;
42 import java.util.SortedSet;
43 import java.util.TreeSet;
44 import org.onap.portalapp.portal.domain.CentralV2RoleFunction;
45
46 @SuppressWarnings("rawtypes")
47 public class CentralV2Role implements Serializable, Comparable {
48     /**
49     *
50     */
51     private static final long serialVersionUID = -4332644961113063714L;
52     private Long id;
53     private Date created;
54     private Date modified;
55     private Long createdId;
56     private Long modifiedId;
57     private Long rowNum;
58
59     private String name;
60     private boolean active;
61     private Integer priority;
62
63     private SortedSet<CentralV2RoleFunction> roleFunctions = new TreeSet<>();
64
65     private SortedSet<CentralV2Role> childRoles = new TreeSet<>();
66
67     private SortedSet<CentralV2Role> parentRoles = new TreeSet<>();
68
69     public CentralV2Role(CentralV2RoleBuilder builder) {
70         super();
71         this.id = builder.id;
72         this.created = builder.created;
73         this.modified = builder.modified;
74         this.createdId = builder.createdId;
75         this.modifiedId = builder.modifiedId;
76         this.rowNum = builder.rowNum;
77         this.name = builder.name;
78         this.active = builder.active;
79         this.priority = builder.priority;
80         this.roleFunctions = builder.roleFunctions;
81         this.childRoles = builder.childRoles;
82         this.parentRoles = builder.parentRoles;
83     }
84
85     public CentralV2Role() {
86
87     }
88
89     public CentralV2Role(Long id, String name) {
90         this.id = id;
91         this.name = name;
92     }
93
94     public static class CentralV2RoleBuilder {
95         private Long id;
96         private Date created;
97         private Date modified;
98         private Long createdId;
99         private Long modifiedId;
100         private Long rowNum;
101         private String name;
102         private boolean active;
103         private Integer priority;
104         private SortedSet<CentralV2RoleFunction> roleFunctions;
105         private SortedSet<CentralV2Role> childRoles;
106         private SortedSet<CentralV2Role> parentRoles;
107
108         public CentralV2RoleBuilder setId(Long id) {
109             this.id = id;
110             return this;
111         }
112
113         public CentralV2RoleBuilder setCreated(Date created) {
114             this.created = created;
115             return this;
116         }
117
118         public CentralV2RoleBuilder setModified(Date modified) {
119             this.modified = modified;
120             return this;
121         }
122
123         public CentralV2RoleBuilder setCreatedId(Long createdId) {
124             this.createdId = createdId;
125             return this;
126         }
127
128         public CentralV2RoleBuilder setModifiedId(Long modifiedId) {
129             this.modifiedId = modifiedId;
130             return this;
131         }
132
133         public CentralV2RoleBuilder setRowNum(Long rowNum) {
134             this.rowNum = rowNum;
135             return this;
136         }
137
138         public CentralV2RoleBuilder setName(String name) {
139             this.name = name;
140             return this;
141         }
142
143         public CentralV2RoleBuilder setActive(boolean active) {
144             this.active = active;
145             return this;
146         }
147
148         public CentralV2RoleBuilder setPriority(Integer priority) {
149             this.priority = priority;
150             return this;
151         }
152
153         public CentralV2RoleBuilder setRoleFunctions(SortedSet<CentralV2RoleFunction> roleFunctions) {
154             this.roleFunctions = roleFunctions;
155             return this;
156         }
157
158         public CentralV2RoleBuilder setChildRoles(SortedSet<CentralV2Role> childRoles) {
159             this.childRoles = childRoles;
160             return this;
161         }
162
163         public CentralV2RoleBuilder setParentRoles(SortedSet<CentralV2Role> parentRoles) {
164             this.parentRoles = parentRoles;
165             return this;
166         }
167
168         public CentralV2Role createCentralV2Role() {
169             return new CentralV2Role(this);
170         }
171     }
172
173     public Long getId() {
174         return id;
175     }
176
177     public void setId(Long id) {
178         this.id = id;
179     }
180
181     public Date getCreated() {
182         return created;
183     }
184
185     public void setCreated(Date created) {
186         this.created = created;
187     }
188
189     public Date getModified() {
190         return modified;
191     }
192
193     public void setModified(Date modified) {
194         this.modified = modified;
195     }
196
197     public Long getCreatedId() {
198         return createdId;
199     }
200
201     public void setCreatedId(Long createdId) {
202         this.createdId = createdId;
203     }
204
205     public Long getModifiedId() {
206         return modifiedId;
207     }
208
209     public void setModifiedId(Long modifiedId) {
210         this.modifiedId = modifiedId;
211     }
212
213     public Long getRowNum() {
214         return rowNum;
215     }
216
217     public void setRowNum(Long rowNum) {
218         this.rowNum = rowNum;
219     }
220
221     public String getName() {
222         return name;
223     }
224
225     public void setName(String name) {
226         this.name = name;
227     }
228
229     public boolean getActive() {
230         return active;
231     }
232
233     public void setActive(boolean active) {
234         this.active = active;
235     }
236
237     public Integer getPriority() {
238         return priority;
239     }
240
241     public void setPriority(Integer priority) {
242         this.priority = priority;
243     }
244
245     public SortedSet<CentralV2RoleFunction> getRoleFunctions() {
246         return roleFunctions;
247     }
248
249     public void setRoleFunctions(SortedSet<CentralV2RoleFunction> roleFunctions) {
250         this.roleFunctions = roleFunctions;
251     }
252
253     public SortedSet<CentralV2Role> getChildRoles() {
254         return childRoles;
255     }
256
257     public void setChildRoles(SortedSet<CentralV2Role> childRoles) {
258         this.childRoles = childRoles;
259     }
260
261     public SortedSet<CentralV2Role> getParentRoles() {
262         return parentRoles;
263     }
264
265     public void setParentRoles(SortedSet<CentralV2Role> parentRoles) {
266         this.parentRoles = parentRoles;
267     }
268
269     public void addRoleFunction(CentralV2RoleFunction roleFunction) {
270         this.roleFunctions.add(roleFunction);
271     }
272
273     public void addChildRole(CentralV2Role role) {
274         this.childRoles.add(role);
275     }
276
277     public void addParentRole(CentralV2Role role) {
278         this.parentRoles.add(role);
279     }
280
281     public int compareTo(Object obj) {
282         CentralV2Role other = (CentralV2Role) obj;
283
284         String c1 = getName();
285         String c2 = other.getName();
286
287         return (c1 == null || c2 == null) ? 1 : c1.compareTo(c2);
288     }
289
290     @Override
291     public int hashCode() {
292         final int prime = 31;
293         int result = 1;
294         result = prime * result + ((id == null) ? 0 : id.hashCode());
295         result = prime * result + ((name == null) ? 0 : name.hashCode());
296         return result;
297     }
298
299     @Override
300     public boolean equals(Object obj) {
301         if (this == obj)
302             return true;
303         if (obj == null)
304             return false;
305         if (getClass() != obj.getClass())
306             return false;
307         CentralV2Role other = (CentralV2Role) obj;
308         if (id == null) {
309             if (other.id != null)
310                 return false;
311         } else if (!id.equals(other.id)) {
312             return false;
313         }
314         if (name == null) {
315             if (other.name != null)
316                 return false;
317         } else if (!name.equals(other.name)) {
318             return false;
319         }
320         return true;
321     }
322 }