de576ad76772491dc8c12e663e077987c5e938a9
[portal.git] / ecomp-portal-BE-common / src / main / java / org / openecomp / portalapp / portal / transport / CentralRole.java
1 package org.openecomp.portalapp.portal.transport;
2
3 import java.util.Date;
4 import java.util.SortedSet;
5
6 import org.openecomp.portalapp.portal.domain.CentralRoleFunction;
7 import org.openecomp.portalapp.portal.domain.EPRole;
8
9 public class CentralRole implements Comparable{
10                 public Long id;
11                 public Date created;
12                 public Date modified;
13                 public Long createdId;
14                 public Long modifiedId;
15                 public Long rowNum;
16                 
17             public String  name;
18             public boolean active;
19             public Integer priority;
20             
21             public SortedSet<CentralRoleFunction> roleFunctions = null;
22             
23             public SortedSet<CentralRole> childRoles = null;
24
25             public SortedSet<CentralRole> parentRoles = null;
26
27                 public CentralRole(Long id, Date created, Date modified, Long createdId, Long modifiedId, Long rowNum,
28                                 String name, boolean active, Integer priority, SortedSet<CentralRoleFunction> roleFunctions,
29                                 SortedSet<CentralRole> childRoles, SortedSet<CentralRole> parentRoles) {
30                         super();
31                         this.id = id;
32                         this.created = created;
33                         this.modified = modified;
34                         this.createdId = createdId;
35                         this.modifiedId = modifiedId;
36                         this.rowNum = rowNum;
37                         this.name = name;
38                         this.active = active;
39                         this.priority = priority;
40                         this.roleFunctions = roleFunctions;
41                         this.childRoles = childRoles;
42                         this.parentRoles = parentRoles;
43                 }
44                 
45                 public CentralRole(){
46                         
47                 }
48                 
49                 public CentralRole(Long id, String name){
50                         this.id = id;
51                         this.name = name;
52                 }
53
54                 public Long getId() {
55                         return id;
56                 }
57
58                 public void setId(Long id) {
59                         this.id = id;
60                 }
61
62                 public Date getCreated() {
63                         return created;
64                 }
65
66                 public void setCreated(Date created) {
67                         this.created = created;
68                 }
69
70                 public Date getModified() {
71                         return modified;
72                 }
73
74                 public void setModified(Date modified) {
75                         this.modified = modified;
76                 }
77
78                 public Long getCreatedId() {
79                         return createdId;
80                 }
81
82                 public void setCreatedId(Long createdId) {
83                         this.createdId = createdId;
84                 }
85
86                 public Long getModifiedId() {
87                         return modifiedId;
88                 }
89
90                 public void setModifiedId(Long modifiedId) {
91                         this.modifiedId = modifiedId;
92                 }
93
94                 public Long getRowNum() {
95                         return rowNum;
96                 }
97
98                 public void setRowNum(Long rowNum) {
99                         this.rowNum = rowNum;
100                 }
101
102                 public String getName() {
103                         return name;
104                 }
105
106                 public void setName(String name) {
107                         this.name = name;
108                 }
109
110                 public boolean isActive() {
111                         return active;
112                 }
113
114                 public void setActive(boolean active) {
115                         this.active = active;
116                 }
117
118                 public Integer getPriority() {
119                         return priority;
120                 }
121
122                 public void setPriority(Integer priority) {
123                         this.priority = priority;
124                 }
125
126                 public SortedSet<CentralRoleFunction> getRoleFunctions() {
127                         return roleFunctions;
128                 }
129
130                 public void setRoleFunctions(SortedSet<CentralRoleFunction> roleFunctions) {
131                         this.roleFunctions = roleFunctions;
132                 }
133
134                 public SortedSet<CentralRole> getChildRoles() {
135                         return childRoles;
136                 }
137
138                 public void setChildRoles(SortedSet<CentralRole> childRoles) {
139                         this.childRoles = childRoles;
140                 }
141
142                 public SortedSet<CentralRole> getParentRoles() {
143                         return parentRoles;
144                 }
145
146                 public void setParentRoles(SortedSet<CentralRole> parentRoles) {
147                         this.parentRoles = parentRoles;
148                 }
149                 
150                 public int compareTo(Object obj){
151                 EPRole other = (EPRole)obj;
152
153                 String c1 = getName();
154                 String c2 = other.getName();
155
156                 return (c1 == null || c2 == null) ? 1 : c1.compareTo(c2);
157             }
158
159                 @Override
160                 public int hashCode() {
161                         final int prime = 31;
162                         int result = 1;
163                         result = prime * result + (active ? 1231 : 1237);
164                         result = prime * result + ((childRoles == null) ? 0 : childRoles.hashCode());
165                         result = prime * result + ((created == null) ? 0 : created.hashCode());
166                         result = prime * result + ((createdId == null) ? 0 : createdId.hashCode());
167                         result = prime * result + ((id == null) ? 0 : id.hashCode());
168                         result = prime * result + ((modified == null) ? 0 : modified.hashCode());
169                         result = prime * result + ((modifiedId == null) ? 0 : modifiedId.hashCode());
170                         result = prime * result + ((name == null) ? 0 : name.hashCode());
171                         result = prime * result + ((parentRoles == null) ? 0 : parentRoles.hashCode());
172                         result = prime * result + ((priority == null) ? 0 : priority.hashCode());
173                         result = prime * result + ((roleFunctions == null) ? 0 : roleFunctions.hashCode());
174                         result = prime * result + ((rowNum == null) ? 0 : rowNum.hashCode());
175                         return result;
176                 }
177
178                 @Override
179                 public boolean equals(Object obj) {
180                         if (this == obj)
181                                 return true;
182                         if (obj == null)
183                                 return false;
184                         if (getClass() != obj.getClass())
185                                 return false;
186                         CentralRole other = (CentralRole) obj;
187                         if (active != other.active)
188                                 return false;
189                         if (childRoles == null) {
190                                 if (other.childRoles != null)
191                                         return false;
192                         } else if (!childRoles.equals(other.childRoles))
193                                 return false;
194                         if (created == null) {
195                                 if (other.created != null)
196                                         return false;
197                         } else if (!created.equals(other.created))
198                                 return false;
199                         if (createdId == null) {
200                                 if (other.createdId != null)
201                                         return false;
202                         } else if (!createdId.equals(other.createdId))
203                                 return false;
204                         if (id == null) {
205                                 if (other.id != null)
206                                         return false;
207                         } else if (!id.equals(other.id))
208                                 return false;
209                         if (modified == null) {
210                                 if (other.modified != null)
211                                         return false;
212                         } else if (!modified.equals(other.modified))
213                                 return false;
214                         if (modifiedId == null) {
215                                 if (other.modifiedId != null)
216                                         return false;
217                         } else if (!modifiedId.equals(other.modifiedId))
218                                 return false;
219                         if (name == null) {
220                                 if (other.name != null)
221                                         return false;
222                         } else if (!name.equals(other.name))
223                                 return false;
224                         if (parentRoles == null) {
225                                 if (other.parentRoles != null)
226                                         return false;
227                         } else if (!parentRoles.equals(other.parentRoles))
228                                 return false;
229                         if (priority == null) {
230                                 if (other.priority != null)
231                                         return false;
232                         } else if (!priority.equals(other.priority))
233                                 return false;
234                         if (roleFunctions == null) {
235                                 if (other.roleFunctions != null)
236                                         return false;
237                         } else if (!roleFunctions.equals(other.roleFunctions))
238                                 return false;
239                         if (rowNum == null) {
240                                 if (other.rowNum != null)
241                                         return false;
242                         } else if (!rowNum.equals(other.rowNum))
243                                 return false;
244                         return true;
245                 }
246
247 }