-
Notifications
You must be signed in to change notification settings - Fork 333
Expand file tree
/
Copy pathCrashLog.java
More file actions
154 lines (135 loc) · 3.99 KB
/
CrashLog.java
File metadata and controls
154 lines (135 loc) · 3.99 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
package datadog.crashtracking.dto;
import com.squareup.moshi.Json;
import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.Moshi;
import datadog.trace.util.RandomUtils;
import java.io.IOException;
import java.util.Objects;
public final class CrashLog {
private static final int VERSION = 0;
public static final JsonAdapter<CrashLog> ADAPTER;
static {
Moshi moshi = new Moshi.Builder().add(new SemanticVersion.SemanticVersionAdapter()).build();
ADAPTER = moshi.adapter(CrashLog.class);
}
public final String uuid;
@Json(name = "data_schema_version")
public final String dataSchemaVersion;
public final String timestamp;
public final boolean incomplete;
public final ErrorData error;
public final Metadata metadata;
@Json(name = "os_info")
public final OSInfo osInfo;
@Json(name = "proc_info")
public final ProcInfo procInfo;
@Json(name = "version_id")
public final int version = VERSION;
@Json(name = "sig_info")
public final SigInfo sigInfo;
public final Experimental experimental;
public CrashLog(
String uuid,
boolean incomplete,
String timestamp,
ErrorData error,
Metadata metadata,
OSInfo osInfo,
ProcInfo procInfo,
SigInfo sigInfo,
String dataSchemaVersion) {
this(
uuid,
incomplete,
timestamp,
error,
metadata,
osInfo,
procInfo,
sigInfo,
dataSchemaVersion,
null);
}
public CrashLog(
String uuid,
boolean incomplete,
String timestamp,
ErrorData error,
Metadata metadata,
OSInfo osInfo,
ProcInfo procInfo,
SigInfo sigInfo,
String dataSchemaVersion,
Experimental experimental) {
this.uuid = uuid != null ? uuid : RandomUtils.randomUUID().toString();
this.incomplete = incomplete;
this.timestamp = timestamp;
this.error = error;
this.metadata = metadata;
this.osInfo = osInfo;
this.procInfo = procInfo;
this.sigInfo = sigInfo;
this.dataSchemaVersion = dataSchemaVersion;
this.experimental = experimental;
}
public String toJson() {
return ADAPTER.toJson(this);
}
public static CrashLog fromJson(String json) throws IOException {
return ADAPTER.fromJson(json);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CrashLog crashLog = (CrashLog) o;
return incomplete == crashLog.incomplete
&& Objects.equals(uuid, crashLog.uuid)
&& Objects.equals(timestamp, crashLog.timestamp)
&& Objects.equals(error, crashLog.error)
&& Objects.equals(metadata, crashLog.metadata)
&& Objects.equals(osInfo, crashLog.osInfo)
&& Objects.equals(procInfo, crashLog.procInfo)
&& Objects.equals(sigInfo, crashLog.sigInfo)
&& Objects.equals(dataSchemaVersion, crashLog.dataSchemaVersion)
&& Objects.equals(experimental, crashLog.experimental);
}
@Override
public int hashCode() {
return Objects.hash(
uuid,
timestamp,
incomplete,
error,
metadata,
osInfo,
procInfo,
sigInfo,
version,
dataSchemaVersion,
experimental);
}
public boolean equalsForTest(Object o) {
// for tests, we need to ignore OSInfo and Metadata part
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CrashLog crashLog = (CrashLog) o;
return incomplete == crashLog.incomplete
&& version == crashLog.version
&& Objects.equals(uuid, crashLog.uuid)
&& Objects.equals(timestamp, crashLog.timestamp)
&& Objects.equals(error, crashLog.error)
&& Objects.equals(procInfo, crashLog.procInfo)
&& Objects.equals(sigInfo, crashLog.sigInfo)
&& Objects.equals(dataSchemaVersion, crashLog.dataSchemaVersion)
&& Objects.equals(experimental, crashLog.experimental);
}
}