-
Notifications
You must be signed in to change notification settings - Fork 1k
/
BackendQuery.java
54 lines (45 loc) · 1.43 KB
/
BackendQuery.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
package org.graylog.plugins.enterprise.search.engine;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import java.util.Objects;
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = BackendQuery.TYPE_FIELD,
visible = true,
defaultImpl = BackendQuery.Fallback.class)
@JsonAutoDetect
public interface BackendQuery {
String TYPE_FIELD = "type";
String type();
@JsonAutoDetect
class Fallback implements BackendQuery {
@JsonProperty
private String type;
@Override
public String type() {
return type;
}
@JsonAnySetter
public void setType(String key, Object value) {
// we ignore all the other values, we only want to be able to deserialize unknown objects
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Fallback fallback = (Fallback) o;
return Objects.equals(type, fallback.type);
}
@Override
public int hashCode() {
return Objects.hash(type);
}
}
}