This repository has been archived by the owner on Aug 30, 2023. It is now read-only.
/
Breadcrumb.java
129 lines (101 loc) · 2.78 KB
/
Breadcrumb.java
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
package io.sentry.core;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.TestOnly;
public final class Breadcrumb implements Cloneable, IUnknownPropertiesConsumer {
private final Date timestamp;
private String message;
private String type;
private Map<String, String> data;
private String category;
private SentryLevel level;
private Map<String, Object> unknown;
Breadcrumb(final Date timestamp) {
this.timestamp = timestamp;
}
public Breadcrumb() {
this(DateUtils.getCurrentDateTime());
}
public Breadcrumb(String message) {
this();
this.message = message;
}
public Date getTimestamp() {
return (Date) timestamp.clone();
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Map<String, String> getData() {
return data;
}
public void setData(Map<String, String> data) {
this.data = data;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public SentryLevel getLevel() {
return level;
}
public void setLevel(SentryLevel level) {
this.level = level;
}
@ApiStatus.Internal
@Override
public void acceptUnknownProperties(Map<String, Object> unknown) {
this.unknown = unknown;
}
@TestOnly
Map<String, Object> getUnknown() {
return unknown;
}
@Override
public Breadcrumb clone() throws CloneNotSupportedException {
final Breadcrumb clone = (Breadcrumb) super.clone();
final Map<String, String> dataRef = data;
if (dataRef != null) {
final Map<String, String> dataClone = new ConcurrentHashMap<>();
for (Map.Entry<String, String> item : dataRef.entrySet()) {
if (item != null) {
dataClone.put(item.getKey(), item.getValue());
}
}
clone.data = dataClone;
} else {
clone.data = null;
}
final Map<String, Object> unknownRef = unknown;
if (unknownRef != null) {
final Map<String, Object> unknownClone = new HashMap<>();
for (Map.Entry<String, Object> item : unknownRef.entrySet()) {
if (item != null) {
unknownClone.put(item.getKey(), item.getValue()); // shallow copy
}
}
clone.unknown = unknownClone;
} else {
clone.unknown = null;
}
final SentryLevel levelRef = level;
clone.level =
levelRef != null ? SentryLevel.valueOf(levelRef.name().toUpperCase(Locale.ROOT)) : null;
return clone;
}
}