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.ExpandableProperty;
20 import com.google.common.base.Objects;
21 import com.google.common.base.Preconditions;
22 import com.google.common.collect.Maps;
23
24 import javax.annotation.Nullable;
25 import java.net.URI;
26 import java.util.Map;
27
28
29
30
31
32
33 public class User extends BasicUser {
34
35 public static String S16_16 = "16x16";
36 public static String S48_48 = "48x48";
37
38 private final String emailAddress;
39
40 private final ExpandableProperty<String> groups;
41
42 private Map<String, URI> avatarUris;
43
44
45
46
47 @Nullable
48 private String timezone;
49
50 public User(URI self, String name, String displayName, String emailAddress, ExpandableProperty<String> groups,
51 Map<String, URI> avatarUris, @Nullable String timezone) {
52 super(self, name, displayName);
53 Preconditions.checkNotNull(avatarUris.get(S48_48), "At least one avatar URL is expected - for 48x48");
54 this.timezone = timezone;
55 this.emailAddress = emailAddress;
56 this.avatarUris = Maps.newHashMap(avatarUris);
57 this.groups = groups;
58 }
59
60 public String getEmailAddress() {
61 return emailAddress;
62 }
63
64 public URI getAvatarUri() {
65 return avatarUris.get(S48_48);
66 }
67
68
69
70
71
72
73 @Nullable
74 public URI getSmallAvatarUri() {
75 return avatarUris.get(S16_16);
76 }
77
78
79
80
81
82
83
84 @SuppressWarnings("UnusedDeclaration")
85 @Nullable
86 public URI getAvatarUri(String sizeDefinition) {
87 return avatarUris.get(sizeDefinition);
88 }
89
90
91
92
93 public ExpandableProperty<String> getGroups() {
94 return groups;
95 }
96
97 @Override
98 public boolean equals(Object obj) {
99 if (obj instanceof User) {
100 User that = (User) obj;
101 return super.equals(obj) && Objects.equal(this.emailAddress, that.emailAddress)
102 && Objects.equal(this.avatarUris, that.avatarUris);
103 }
104 return false;
105 }
106
107
108
109
110
111
112 @Nullable
113 public String getTimezone() {
114 return timezone;
115 }
116
117 @Override
118 public String toString() {
119 return Objects.toStringHelper(this).addValue(super.toString()).
120 add("emailAddress", emailAddress).
121 add("avatarUris", avatarUris).
122 add("groups", groups).
123 toString();
124 }
125
126 }