1 /*
2 * Copyright (C) 2010 Atlassian
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package com.atlassian.jira.rest.client.api.domain;
18
19 import com.google.common.base.Objects;
20
21 import java.net.URI;
22
23 /**
24 * Basic information about a JIRA user
25 *
26 * @since v0.1
27 */
28 public class BasicUser extends AddressableNamedEntity {
29
30 /**
31 * This value is used to mark incomplete user URI - when server response with user without selfUri set.
32 * This may happen due to bug in JIRA REST API - for example in JRA-30263 bug, JIRA REST API will return
33 * user without selfUri for deleted author of worklog entry.
34 */
35 public static URI INCOMPLETE_URI = URI.create("incomplete://user");
36
37 private final String displayName;
38
39 public BasicUser(URI self, String name, String displayName) {
40 super(self, name);
41 this.displayName = displayName;
42 }
43
44 public String getDisplayName() {
45 return displayName;
46 }
47
48 @Override
49 protected Objects.ToStringHelper getToStringHelper() {
50 return super.getToStringHelper()
51 .add("displayName", displayName);
52 }
53
54 @Override
55 public boolean equals(Object obj) {
56 if (obj instanceof BasicUser) {
57 BasicUser that = (BasicUser) obj;
58 return super.equals(that) && Objects.equal(this.displayName, that.displayName);
59 }
60 return false;
61 }
62
63 @Override
64 public int hashCode() {
65 return Objects.hashCode(super.hashCode(), displayName);
66 }
67
68 /**
69 * @return true when URI returned from server was incomplete. See {@link BasicUser#INCOMPLETE_URI} for more detail.
70 */
71 public boolean isSelfUriIncomplete() {
72 return INCOMPLETE_URI.equals(self);
73 }
74
75 }