-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathRxFirebaseChildEvent.java
More file actions
91 lines (75 loc) · 2.48 KB
/
RxFirebaseChildEvent.java
File metadata and controls
91 lines (75 loc) · 2.48 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
package durdinapps.rxfirebase2;
import androidx.annotation.NonNull;
public class RxFirebaseChildEvent<T> {
private final EventType eventType;
private final String key;
private final T value;
private String previousChildName;
public RxFirebaseChildEvent(@NonNull String key,
@NonNull T value,
@NonNull String previousChildName,
@NonNull EventType eventType) {
this.key = key;
this.value = value;
this.previousChildName = previousChildName;
this.eventType = eventType;
}
public RxFirebaseChildEvent(@NonNull String key, @NonNull T data, @NonNull EventType eventType) {
this.key = key;
this.value = data;
this.eventType = eventType;
}
/**
* @return the key associate to this {@link RxFirebaseChildEvent};
*/
@NonNull
public String getKey() {
return key;
}
/**
* @return the value associate to this {@link RxFirebaseChildEvent};
*/
@NonNull
public T getValue() {
return value;
}
/**
* @return the previous child name at this position;
*/
@NonNull
public String getPreviousChildName() {
return previousChildName;
}
/**
* @return the kind of event of this event. This is used to different them when an item is added, changed, moved or removed.
*/
@NonNull
public EventType getEventType() {
return eventType;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RxFirebaseChildEvent<?> that = (RxFirebaseChildEvent<?>) o;
if (eventType != that.eventType) return false;
if (value != null ? !value.equals(that.value) : that.value != null) return false;
return previousChildName != null ? previousChildName.equals(that.previousChildName) : that.previousChildName == null;
}
@Override
public int hashCode() {
int result = eventType != null ? eventType.hashCode() : 0;
result = 31 * result + (value != null ? value.hashCode() : 0);
result = 31 * result + (previousChildName != null ? previousChildName.hashCode() : 0);
return result;
}
/**
* Enum used to different when an item is added, changed, moved or removed.
*/
public enum EventType {
ADDED,
CHANGED,
REMOVED,
MOVED
}
}