1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
27
28
29
30 public class AddressableNamedEntity implements AddressableEntity, NamedEntity {
31 protected final URI self;
32 protected final String name;
33
34 public AddressableNamedEntity(URI self, String name) {
35 this.name = name;
36 this.self = self;
37 }
38
39 @Override
40 public URI getSelf() {
41 return self;
42 }
43
44 public String getName() {
45 return name;
46 }
47
48 @Override
49 public String toString() {
50 return getToStringHelper().toString();
51 }
52
53 protected Objects.ToStringHelper getToStringHelper() {
54 return Objects.toStringHelper(this).
55 add("self", self).
56 add("name", name);
57 }
58
59 @Override
60 public boolean equals(Object obj) {
61 if (obj instanceof AddressableNamedEntity) {
62 AddressableNamedEntity that = (AddressableNamedEntity) obj;
63 return Objects.equal(this.self, that.self)
64 && Objects.equal(this.name, that.name);
65 }
66 return false;
67 }
68
69 @Override
70 public int hashCode() {
71 return Objects.hashCode(self, name);
72 }
73 }