2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
20 package org.openecomp.portalapp.portal.domain;
23 @SuppressWarnings("rawtypes")
24 public class EPUserApp implements java.io.Serializable, Comparable {
26 private static final long serialVersionUID = 1L;
31 private Short priority;
36 public Long getAppId() {
37 return this.getApp().getId();
40 public Long getRoleId() {
41 return (role == null) ? null : role.getId();
44 public Long getAppRoleId() {
45 return (role.getAppRoleId() == null) ? null : role.getAppRoleId();
49 public String toString() {
50 String str = "[u: "+getUserId()+"; a: "+getAppId()+", r: "+getRoleId()+"; appRoleId: "+getAppRoleId()+"]";
54 public Long getUserId() {
58 public void setUserId(Long id) {
62 public EPApp getApp() {
66 public void setApp(EPApp app) {
70 public EPRole getRole() {
74 public void setRole(EPRole role) {
78 public Short getPriority() {
82 public void setPriority(Short priority) {
83 this.priority = priority;
86 public boolean equals(Object other) {
91 if (!(other instanceof EPUserApp))
93 EPUserApp castOther = (EPUserApp) other;
95 return (this.getUserId().equals(castOther.getUserId()))
96 && (this.getApp().getId().equals(castOther.getApp().getId()))
97 && (this.getRole().getId().equals(castOther.getRole().getId()))
98 && ((this.priority==null && castOther.getPriority()==null) || this.getPriority().equals(castOther.getPriority()));
101 public int hashCode() {
104 result = 37 * result + (int) (this.getUserId()==null ? 0 : this.getUserId().intValue());
105 result = 37 * result + (int) (this.getApp().getId()==null ? 0 : this.getApp().getId().intValue());
106 result = 37 * result + (int) (this.getRole().getId()==null ? 0 : this.getRole().getId().intValue());
107 result = 37 * result + (int) (this.priority==null ? 0 : this.priority);
111 public int compareTo(Object other){
112 EPUserApp castOther = (EPUserApp) other;
114 Long c1 = (this.getUserId()==null ? 0 : this.getUserId()) + (this.getApp()==null||this.getApp().getId()==null ? 0 : this.getApp().getId()) + (this.getRole()==null||this.getRole().getId()==null ? 0 : this.getRole().getId()) + (this.priority==null ? 0 : this.priority);
115 Long c2 = (castOther.getUserId()==null ? 0 : castOther.getUserId()) + (castOther.getApp()==null||castOther.getApp().getId()==null ? 0 : castOther.getApp().getId()) + (castOther.getRole()==null||castOther.getRole().getId()==null ? 0 : castOther.getRole().getId()) + (castOther.priority==null ? 0 : castOther.priority);
117 return c1.compareTo(c2);