2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
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
26 * https://creativecommons.org/licenses/by/4.0/
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.
34 * ============LICENSE_END============================================
38 package org.onap.portalapp.portal.transport;
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;
46 @SuppressWarnings("rawtypes")
47 public class CentralV2Role implements Serializable, Comparable {
51 private static final long serialVersionUID = -4332644961113063714L;
54 private Date modified;
55 private Long createdId;
56 private Long modifiedId;
60 private boolean active;
61 private Integer priority;
63 private SortedSet<CentralV2RoleFunction> roleFunctions = new TreeSet<>();
65 private SortedSet<CentralV2Role> childRoles = new TreeSet<>();
67 private SortedSet<CentralV2Role> parentRoles = new TreeSet<>();
69 public CentralV2Role(CentralV2RoleBuilder builder) {
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;
85 public CentralV2Role() {
89 public CentralV2Role(Long id, String name) {
94 public static class CentralV2RoleBuilder {
97 private Date modified;
98 private Long createdId;
99 private Long modifiedId;
102 private boolean active;
103 private Integer priority;
104 private SortedSet<CentralV2RoleFunction> roleFunctions;
105 private SortedSet<CentralV2Role> childRoles;
106 private SortedSet<CentralV2Role> parentRoles;
108 public CentralV2RoleBuilder setId(Long id) {
113 public CentralV2RoleBuilder setCreated(Date created) {
114 this.created = created;
118 public CentralV2RoleBuilder setModified(Date modified) {
119 this.modified = modified;
123 public CentralV2RoleBuilder setCreatedId(Long createdId) {
124 this.createdId = createdId;
128 public CentralV2RoleBuilder setModifiedId(Long modifiedId) {
129 this.modifiedId = modifiedId;
133 public CentralV2RoleBuilder setRowNum(Long rowNum) {
134 this.rowNum = rowNum;
138 public CentralV2RoleBuilder setName(String name) {
143 public CentralV2RoleBuilder setActive(boolean active) {
144 this.active = active;
148 public CentralV2RoleBuilder setPriority(Integer priority) {
149 this.priority = priority;
153 public CentralV2RoleBuilder setRoleFunctions(SortedSet<CentralV2RoleFunction> roleFunctions) {
154 this.roleFunctions = roleFunctions;
158 public CentralV2RoleBuilder setChildRoles(SortedSet<CentralV2Role> childRoles) {
159 this.childRoles = childRoles;
163 public CentralV2RoleBuilder setParentRoles(SortedSet<CentralV2Role> parentRoles) {
164 this.parentRoles = parentRoles;
168 public CentralV2Role createCentralV2Role() {
169 return new CentralV2Role(this);
173 public Long getId() {
177 public void setId(Long id) {
181 public Date getCreated() {
185 public void setCreated(Date created) {
186 this.created = created;
189 public Date getModified() {
193 public void setModified(Date modified) {
194 this.modified = modified;
197 public Long getCreatedId() {
201 public void setCreatedId(Long createdId) {
202 this.createdId = createdId;
205 public Long getModifiedId() {
209 public void setModifiedId(Long modifiedId) {
210 this.modifiedId = modifiedId;
213 public Long getRowNum() {
217 public void setRowNum(Long rowNum) {
218 this.rowNum = rowNum;
221 public String getName() {
225 public void setName(String name) {
229 public boolean getActive() {
233 public void setActive(boolean active) {
234 this.active = active;
237 public Integer getPriority() {
241 public void setPriority(Integer priority) {
242 this.priority = priority;
245 public SortedSet<CentralV2RoleFunction> getRoleFunctions() {
246 return roleFunctions;
249 public void setRoleFunctions(SortedSet<CentralV2RoleFunction> roleFunctions) {
250 this.roleFunctions = roleFunctions;
253 public SortedSet<CentralV2Role> getChildRoles() {
257 public void setChildRoles(SortedSet<CentralV2Role> childRoles) {
258 this.childRoles = childRoles;
261 public SortedSet<CentralV2Role> getParentRoles() {
265 public void setParentRoles(SortedSet<CentralV2Role> parentRoles) {
266 this.parentRoles = parentRoles;
269 public void addRoleFunction(CentralV2RoleFunction roleFunction) {
270 this.roleFunctions.add(roleFunction);
273 public void addChildRole(CentralV2Role role) {
274 this.childRoles.add(role);
277 public void addParentRole(CentralV2Role role) {
278 this.parentRoles.add(role);
281 public int compareTo(Object obj) {
282 CentralV2Role other = (CentralV2Role) obj;
284 String c1 = getName();
285 String c2 = other.getName();
287 return (c1 == null || c2 == null) ? 1 : c1.compareTo(c2);
291 public int hashCode() {
292 final int prime = 31;
294 result = prime * result + ((id == null) ? 0 : id.hashCode());
295 result = prime * result + ((name == null) ? 0 : name.hashCode());
300 public boolean equals(Object obj) {
305 if (getClass() != obj.getClass())
307 CentralV2Role other = (CentralV2Role) obj;
309 if (other.id != null)
311 } else if (!id.equals(other.id)) {
315 if (other.name != null)
317 } else if (!name.equals(other.name)) {