blob: 4ed5205996d555207fe42575416acc5aa6fb6453 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/*******************************************************************************
* Copyright (c) 2012 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.ats.core.users;
import org.eclipse.osee.ats.api.user.IAtsUser;
import org.eclipse.osee.framework.jdk.core.type.Identity;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
/**
* @author Donald G. Dunne
*/
public abstract class AbstractAtsUser implements IAtsUser {
private String userId;
protected AbstractAtsUser(String userId) {
this.userId = userId;
}
@Override
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
@Override
public String getDescription() {
return getName();
}
@Override
public String getEmail() {
return "";
}
@Override
public String toString() {
return String.format("User [%s - %s - %s]", getName(), getUserId(), getEmail());
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((userId == null) ? 0 : userId.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof IAtsUser)) {
return false;
}
try {
String thisUserId = getUserId();
String objUserId = ((IAtsUser) obj).getUserId();
if (thisUserId == null) {
if (objUserId != null) {
return false;
}
} else if (!thisUserId.equals(objUserId)) {
return false;
}
} catch (OseeCoreException ex) {
return false;
}
return true;
}
@Override
public int compareTo(Object other) {
int result = other != null ? -1 : 1;
if (other instanceof IAtsUser) {
String otherName = ((IAtsUser) other).getName();
String thisName = getName();
if (thisName == null && otherName == null) {
result = 0;
} else if (thisName != null && otherName == null) {
result = 1;
} else if (thisName != null && otherName != null) {
result = thisName.compareTo(otherName);
}
}
return result;
}
@Override
public boolean isActive() {
return true;
}
@Override
public boolean matches(Identity<?>... identities) {
for (Identity<?> identity : identities) {
if (equals(identity)) {
return true;
}
}
return false;
}
@Override
public String toStringWithId() {
return String.format("[%s][%s]", getName(), getGuid());
}
}
|