-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathKeyImpression.java
More file actions
89 lines (68 loc) · 2.84 KB
/
Copy pathKeyImpression.java
File metadata and controls
89 lines (68 loc) · 2.84 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
package io.split.client.dtos;
import com.google.gson.annotations.SerializedName;
import io.split.client.impressions.Impression;
import java.util.Objects;
public class KeyImpression {
/* package private */ static final String FIELD_KEY_NAME = "k";
/* package private */ static final String FIELD_BUCKETING_KEY = "b";
/* package private */ static final String FIELD_TREATMENT = "t";
/* package private */ static final String FIELD_LABEL = "r";
/* package private */ static final String FIELD_TIME = "m";
/* package private */ static final String FIELD_CHANGE_NUMBER = "c";
/* package private */ static final String FIELD_PREVIOUS_TIME = "pt";
/* package private */ static final String FIELD_PROPERTIES = "properties";
public transient String feature; // Non-serializable
@SerializedName(FIELD_KEY_NAME)
public String keyName;
@SerializedName(FIELD_BUCKETING_KEY)
public String bucketingKey;
@SerializedName(FIELD_TREATMENT)
public String treatment;
@SerializedName(FIELD_LABEL)
public String label;
@SerializedName(FIELD_TIME)
public long time;
@SerializedName(FIELD_CHANGE_NUMBER)
public Long changeNumber; // can be null if there is no changeNumber
@SerializedName(FIELD_PREVIOUS_TIME)
public Long previousTime;
@SerializedName(FIELD_PROPERTIES)
public String properties;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
KeyImpression that = (KeyImpression) o;
if (time != that.time) return false;
if (!Objects.equals(feature, that.feature)) return false;
if (!keyName.equals(that.keyName)) return false;
if (!treatment.equals(that.treatment)) return false;
if (properties != null && !properties.equals(that.properties)) return false;
if (bucketingKey == null) {
return that.bucketingKey == null;
}
return bucketingKey.equals(that.bucketingKey);
}
@Override
public int hashCode() {
int result = feature != null ? feature.hashCode() : 0;
result = 31 * result + keyName.hashCode();
result = 31 * result + (bucketingKey == null ? 0 : bucketingKey.hashCode());
result = 31 * result + treatment.hashCode();
result = 31 * result + (int) (time ^ (time >>> 32));
return result;
}
public static KeyImpression fromImpression(Impression i) {
KeyImpression ki = new KeyImpression();
ki.feature = i.split();
ki.keyName = i.key();
ki.bucketingKey = i.bucketingKey();
ki.time = i.time();
ki.changeNumber = i.changeNumber();
ki.treatment = i.treatment();
ki.label = i.appliedRule();
ki.previousTime = i.pt();
ki.properties = i.properties();
return ki;
}
}