View Javadoc

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.domain;
18  
19  import com.atlassian.jira.rest.client.AddressableEntity;
20  import com.atlassian.jira.rest.client.NamedEntity;
21  import com.google.common.base.Objects;
22  
23  import java.net.URI;
24  
25  /**
26   * Basic information about a JIRA user
27   *
28   * @since v0.1
29   */
30  public class BasicUser implements AddressableEntity, NamedEntity {
31      private final String name;
32      private final String displayName;
33      private final URI self;
34  
35      public BasicUser(URI self, String name, String displayName) {
36          this.self = self;
37          this.name = name;
38          this.displayName = displayName;
39      }
40  
41      public String getName() {
42          return name;
43      }
44  
45      public String getDisplayName() {
46          return displayName;
47      }
48  
49  
50  
51      @Override
52  	public URI getSelf() {
53          return self;
54      }
55  
56      @Override
57      public String toString() {
58          return Objects.toStringHelper(this).add("name", name)
59                  .add("displayName", displayName).add("self", self).toString();
60      }
61  
62      @Override
63      public boolean equals(Object obj) {
64          if (obj instanceof BasicUser) {
65              BasicUser that = (BasicUser) obj;
66              return Objects.equal(this.self, that.self)
67                      && Objects.equal(this.name, that.name)
68                      && Objects.equal(this.displayName, that.displayName);
69          }
70          return false;
71      }
72  
73      @Override
74      public int hashCode() {
75          return Objects.hashCode(self, name, displayName);
76      }
77  
78  }