Skip to content

Commit 1460f26

Browse files
committed
fix format
1 parent 9759f40 commit 1460f26

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

firebase-firestore/src/main/java/com/google/firebase/firestore/Filter.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.firebase.firestore.core.FieldFilter.Operator;
2020
import java.util.Arrays;
2121
import java.util.List;
22+
import java.util.Objects;
2223

2324
/**
2425
* A {@code Filter} represents a restriction on one or more field values and can be used to refine
@@ -48,6 +49,26 @@ public Operator getOperator() {
4849
public Object getValue() {
4950
return value;
5051
}
52+
53+
@Override
54+
public boolean equals(Object o) {
55+
if (this == o) return true;
56+
if (o == null || getClass() != o.getClass()) return false;
57+
58+
UnaryFilter that = (UnaryFilter) o;
59+
60+
return this.operator == that.operator
61+
&& Objects.equals(this.field, that.field)
62+
&& Objects.equals(this.value, that.value);
63+
}
64+
65+
@Override
66+
public int hashCode() {
67+
int result = field != null ? field.hashCode() : 0;
68+
result = 31 * result + (operator != null ? operator.hashCode() : 0);
69+
result = 31 * result + (value != null ? value.hashCode() : 0);
70+
return result;
71+
}
5172
}
5273

5374
static class CompositeFilter extends Filter {
@@ -68,6 +89,23 @@ public List<Filter> getFilters() {
6889
public com.google.firebase.firestore.core.CompositeFilter.Operator getOperator() {
6990
return operator;
7091
}
92+
93+
@Override
94+
public boolean equals(Object o) {
95+
if (this == o) return true;
96+
if (o == null || getClass() != o.getClass()) return false;
97+
98+
CompositeFilter that = (CompositeFilter) o;
99+
100+
return this.operator == that.operator && Objects.equals(this.filters, that.filters);
101+
}
102+
103+
@Override
104+
public int hashCode() {
105+
int result = filters != null ? filters.hashCode() : 0;
106+
result = 31 * result + (operator != null ? operator.hashCode() : 0);
107+
return result;
108+
}
71109
}
72110

73111
/**

firebase-firestore/src/test/java/com/google/firebase/firestore/FilterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,4 @@ public void and() {
175175
Filter.inArray("y", ImmutableList.of("v3", "v4")),
176176
Filter.inArray("x", ImmutableList.of("v1", "v2"))));
177177
}
178-
}
178+
}

0 commit comments

Comments
 (0)