-
-
Notifications
You must be signed in to change notification settings - Fork 468
Expand file tree
/
Copy pathFilterString.java
More file actions
51 lines (44 loc) · 1.29 KB
/
FilterString.java
File metadata and controls
51 lines (44 loc) · 1.29 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
package io.sentry;
import java.util.Objects;
import java.util.regex.Pattern;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public final class FilterString {
private final @NotNull String filterString;
private final @Nullable Pattern pattern;
public FilterString(@NotNull String filterString) {
this.filterString = filterString;
@Nullable Pattern pattern = null;
try {
pattern = Pattern.compile(filterString);
} catch (Throwable t) {
Sentry.getCurrentScopes()
.getOptions()
.getLogger()
.log(
SentryLevel.DEBUG,
"Only using filter string for String comparison as it could not be parsed as regex: %s",
filterString);
}
this.pattern = pattern;
}
public @NotNull String getFilterString() {
return filterString;
}
public boolean matches(String input) {
if (pattern == null) {
return false;
}
return pattern.matcher(input).matches();
}
@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
FilterString that = (FilterString) o;
return Objects.equals(filterString, that.filterString);
}
@Override
public int hashCode() {
return Objects.hash(filterString);
}
}