forked from getsentry/sentry-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpanId.java
More file actions
41 lines (32 loc) · 912 Bytes
/
SpanId.java
File metadata and controls
41 lines (32 loc) · 912 Bytes
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
package io.sentry;
import io.sentry.util.Objects;
import java.util.UUID;
import org.jetbrains.annotations.NotNull;
public final class SpanId {
public static final SpanId EMPTY_ID = new SpanId(new UUID(0, 0).toString());
private final @NotNull String value;
public SpanId(final @NotNull String value) {
this.value = Objects.requireNonNull(value, "value is required");
}
public SpanId() {
this(UUID.randomUUID());
}
private SpanId(final @NotNull UUID uuid) {
this(uuid.toString().replace("-", "").substring(0, 16));
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SpanId spanId = (SpanId) o;
return value.equals(spanId.value);
}
@Override
public int hashCode() {
return value.hashCode();
}
@Override
public String toString() {
return this.value;
}
}