forked from getsentry/sentry-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.java
More file actions
172 lines (149 loc) · 3.79 KB
/
User.java
File metadata and controls
172 lines (149 loc) · 3.79 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
package io.sentry.protocol;
import io.sentry.IUnknownPropertiesConsumer;
import io.sentry.util.CollectionUtils;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
/**
* Information about the user who triggered an event.
*
* <p>```json { "user": { "id": "unique_id", "username": "my_user", "email": "foo@example.com",
* "ip_address": "127.0.0.1", "subscription": "basic" } } ```
*/
public final class User implements Cloneable, IUnknownPropertiesConsumer {
/** Email address of the user. */
private @Nullable String email;
/** Unique identifier of the user. */
private @Nullable String id;
/** Username of the user. */
private @Nullable String username;
/** Remote IP address of the user. */
private @Nullable String ipAddress;
/**
* Additional arbitrary fields, as stored in the database (and sometimes as sent by clients). All
* data from `self.other` should end up here after store normalization.
*/
private @Nullable Map<String, String> other;
/** unknown fields, only internal usage. */
private @Nullable Map<String, Object> unknown;
/**
* Gets the e-mail address of the user.
*
* @return the e-mail.
*/
public @Nullable String getEmail() {
return email;
}
/**
* Gets the e-mail address of the user.
*
* @param email the e-mail.
*/
public void setEmail(final @Nullable String email) {
this.email = email;
}
/**
* Gets the id of the user.
*
* @return the id.
*/
public @Nullable String getId() {
return id;
}
/**
* Sets the id of the user.
*
* @param id the user id.
*/
public void setId(final @Nullable String id) {
this.id = id;
}
/**
* Gets the username of the user.
*
* @return the username.
*/
public @Nullable String getUsername() {
return username;
}
/**
* Sets the username of the user.
*
* @param username the username.
*/
public void setUsername(final @Nullable String username) {
this.username = username;
}
/**
* Gets the IP address of the user.
*
* @return the IP address of the user.
*/
public @Nullable String getIpAddress() {
return ipAddress;
}
/**
* Sets the IP address of the user.
*
* @param ipAddress the IP address of the user.
*/
public void setIpAddress(final @Nullable String ipAddress) {
this.ipAddress = ipAddress;
}
/**
* Gets other user related data.
*
* @return the other user data.
*/
public @Nullable Map<String, String> getOthers() {
return other;
}
/**
* Sets other user related data.
*
* @param other the other user related data..
*/
public void setOthers(final @Nullable Map<String, String> other) {
if (other != null) {
this.other = new ConcurrentHashMap<>(other);
} else {
this.other = null;
}
}
/**
* User's unknown fields, only internal usage
*
* @param unknown the unknown fields
*/
@ApiStatus.Internal
@Override
public void acceptUnknownProperties(final @NotNull Map<String, Object> unknown) {
this.unknown = new ConcurrentHashMap<>(unknown);
}
/**
* the User's unknown fields
*
* @return the unknown map
*/
@TestOnly
@Nullable
Map<String, Object> getUnknown() {
return unknown;
}
/**
* Clones an User aka deep copy
*
* @return the cloned User
* @throws CloneNotSupportedException if the User is not cloneable
*/
@Override
public @NotNull User clone() throws CloneNotSupportedException {
final User clone = (User) super.clone();
clone.other = CollectionUtils.shallowCopy(other);
clone.unknown = CollectionUtils.shallowCopy(unknown);
return clone;
}
}