Skip to content

Commit 1effa7a

Browse files
authored
Add equals and hashCode to Timeseries Params classes (#3959)
1 parent 2229a34 commit 1effa7a

File tree

8 files changed

+254
-0
lines changed

8 files changed

+254
-0
lines changed

src/main/java/redis/clients/jedis/timeseries/TSAddParams.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import java.util.LinkedHashMap;
77
import java.util.Map;
8+
import java.util.Objects;
89
import redis.clients.jedis.CommandArguments;
910
import redis.clients.jedis.params.IParams;
1011

@@ -125,4 +126,36 @@ public void addParams(CommandArguments args) {
125126
labels.entrySet().forEach((entry) -> args.add(entry.getKey()).add(entry.getValue()));
126127
}
127128
}
129+
130+
@Override
131+
public boolean equals(Object o) {
132+
if (this == o) {
133+
return true;
134+
}
135+
if (o == null || getClass() != o.getClass()) {
136+
return false;
137+
}
138+
139+
TSAddParams that = (TSAddParams) o;
140+
return ignore == that.ignore && ignoreMaxTimediff == that.ignoreMaxTimediff &&
141+
Double.compare(ignoreMaxValDiff, that.ignoreMaxValDiff) == 0 &&
142+
Objects.equals(retentionPeriod, that.retentionPeriod) &&
143+
encoding == that.encoding && Objects.equals(chunkSize, that.chunkSize) &&
144+
duplicatePolicy == that.duplicatePolicy && onDuplicate == that.onDuplicate &&
145+
Objects.equals(labels, that.labels);
146+
}
147+
148+
@Override
149+
public int hashCode() {
150+
int result = Objects.hashCode(retentionPeriod);
151+
result = 31 * result + Objects.hashCode(encoding);
152+
result = 31 * result + Objects.hashCode(chunkSize);
153+
result = 31 * result + Objects.hashCode(duplicatePolicy);
154+
result = 31 * result + Objects.hashCode(onDuplicate);
155+
result = 31 * result + Boolean.hashCode(ignore);
156+
result = 31 * result + Long.hashCode(ignoreMaxTimediff);
157+
result = 31 * result + Double.hashCode(ignoreMaxValDiff);
158+
result = 31 * result + Objects.hashCode(labels);
159+
return result;
160+
}
128161
}

src/main/java/redis/clients/jedis/timeseries/TSAlterParams.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.Collections;
77
import java.util.LinkedHashMap;
88
import java.util.Map;
9+
import java.util.Objects;
910
import redis.clients.jedis.CommandArguments;
1011
import redis.clients.jedis.params.IParams;
1112

@@ -106,4 +107,33 @@ public void addParams(CommandArguments args) {
106107
labels.entrySet().forEach((entry) -> args.add(entry.getKey()).add(entry.getValue()));
107108
}
108109
}
110+
111+
@Override
112+
public boolean equals(Object o) {
113+
if (this == o) {
114+
return true;
115+
}
116+
if (o == null || getClass() != o.getClass()) {
117+
return false;
118+
}
119+
120+
TSAlterParams that = (TSAlterParams) o;
121+
return ignore == that.ignore && ignoreMaxTimediff == that.ignoreMaxTimediff &&
122+
Double.compare(ignoreMaxValDiff, that.ignoreMaxValDiff) == 0 &&
123+
Objects.equals(retentionPeriod, that.retentionPeriod) &&
124+
Objects.equals(chunkSize, that.chunkSize) &&
125+
duplicatePolicy == that.duplicatePolicy && Objects.equals(labels, that.labels);
126+
}
127+
128+
@Override
129+
public int hashCode() {
130+
int result = Objects.hashCode(retentionPeriod);
131+
result = 31 * result + Objects.hashCode(chunkSize);
132+
result = 31 * result + Objects.hashCode(duplicatePolicy);
133+
result = 31 * result + Boolean.hashCode(ignore);
134+
result = 31 * result + Long.hashCode(ignoreMaxTimediff);
135+
result = 31 * result + Double.hashCode(ignoreMaxValDiff);
136+
result = 31 * result + Objects.hashCode(labels);
137+
return result;
138+
}
109139
}

src/main/java/redis/clients/jedis/timeseries/TSArithByParams.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import java.util.LinkedHashMap;
77
import java.util.Map;
8+
import java.util.Objects;
89
import redis.clients.jedis.CommandArguments;
910
import redis.clients.jedis.params.IParams;
1011

@@ -117,4 +118,36 @@ public void addParams(CommandArguments args) {
117118
labels.entrySet().forEach((entry) -> args.add(entry.getKey()).add(entry.getValue()));
118119
}
119120
}
121+
122+
@Override
123+
public boolean equals(Object o) {
124+
if (this == o) {
125+
return true;
126+
}
127+
if (o == null || getClass() != o.getClass()) {
128+
return false;
129+
}
130+
131+
TSArithByParams<?> that = (TSArithByParams<?>) o;
132+
return ignore == that.ignore && ignoreMaxTimediff == that.ignoreMaxTimediff &&
133+
Double.compare(ignoreMaxValDiff, that.ignoreMaxValDiff) == 0 &&
134+
Objects.equals(timestamp, that.timestamp) &&
135+
Objects.equals(retentionPeriod, that.retentionPeriod) &&
136+
encoding == that.encoding && Objects.equals(chunkSize, that.chunkSize) &&
137+
duplicatePolicy == that.duplicatePolicy && Objects.equals(labels, that.labels);
138+
}
139+
140+
@Override
141+
public int hashCode() {
142+
int result = Objects.hashCode(timestamp);
143+
result = 31 * result + Objects.hashCode(retentionPeriod);
144+
result = 31 * result + Objects.hashCode(encoding);
145+
result = 31 * result + Objects.hashCode(chunkSize);
146+
result = 31 * result + Objects.hashCode(duplicatePolicy);
147+
result = 31 * result + Boolean.hashCode(ignore);
148+
result = 31 * result + Long.hashCode(ignoreMaxTimediff);
149+
result = 31 * result + Double.hashCode(ignoreMaxValDiff);
150+
result = 31 * result + Objects.hashCode(labels);
151+
return result;
152+
}
120153
}

src/main/java/redis/clients/jedis/timeseries/TSCreateParams.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import java.util.LinkedHashMap;
77
import java.util.Map;
8+
import java.util.Objects;
89
import redis.clients.jedis.CommandArguments;
910
import redis.clients.jedis.params.IParams;
1011

@@ -121,4 +122,34 @@ public void addParams(CommandArguments args) {
121122
labels.entrySet().forEach((entry) -> args.add(entry.getKey()).add(entry.getValue()));
122123
}
123124
}
125+
126+
@Override
127+
public boolean equals(Object o) {
128+
if (this == o) {
129+
return true;
130+
}
131+
if (o == null || getClass() != o.getClass()) {
132+
return false;
133+
}
134+
135+
TSCreateParams that = (TSCreateParams) o;
136+
return ignore == that.ignore && ignoreMaxTimediff == that.ignoreMaxTimediff &&
137+
Double.compare(ignoreMaxValDiff, that.ignoreMaxValDiff) == 0 &&
138+
Objects.equals(retentionPeriod, that.retentionPeriod) &&
139+
encoding == that.encoding && Objects.equals(chunkSize, that.chunkSize) &&
140+
duplicatePolicy == that.duplicatePolicy && Objects.equals(labels, that.labels);
141+
}
142+
143+
@Override
144+
public int hashCode() {
145+
int result = Objects.hashCode(retentionPeriod);
146+
result = 31 * result + Objects.hashCode(encoding);
147+
result = 31 * result + Objects.hashCode(chunkSize);
148+
result = 31 * result + Objects.hashCode(duplicatePolicy);
149+
result = 31 * result + Boolean.hashCode(ignore);
150+
result = 31 * result + Long.hashCode(ignoreMaxTimediff);
151+
result = 31 * result + Double.hashCode(ignoreMaxValDiff);
152+
result = 31 * result + Objects.hashCode(labels);
153+
return result;
154+
}
124155
}

src/main/java/redis/clients/jedis/timeseries/TSGetParams.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,22 @@ public void addParams(CommandArguments args) {
2727
args.add(LATEST);
2828
}
2929
}
30+
31+
@Override
32+
public boolean equals(Object o) {
33+
if (this == o) {
34+
return true;
35+
}
36+
if (o == null || getClass() != o.getClass()) {
37+
return false;
38+
}
39+
40+
TSGetParams that = (TSGetParams) o;
41+
return latest == that.latest;
42+
}
43+
44+
@Override
45+
public int hashCode() {
46+
return Boolean.hashCode(latest);
47+
}
3048
}

src/main/java/redis/clients/jedis/timeseries/TSMGetParams.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static redis.clients.jedis.timeseries.TimeSeriesProtocol.TimeSeriesKeyword.SELECTED_LABELS;
55
import static redis.clients.jedis.timeseries.TimeSeriesProtocol.TimeSeriesKeyword.WITHLABELS;
66

7+
import java.util.Arrays;
78
import redis.clients.jedis.CommandArguments;
89
import redis.clients.jedis.params.IParams;
910

@@ -55,4 +56,26 @@ public void addParams(CommandArguments args) {
5556
}
5657
}
5758
}
59+
60+
@Override
61+
public boolean equals(Object o) {
62+
if (this == o) {
63+
return true;
64+
}
65+
if (o == null || getClass() != o.getClass()) {
66+
return false;
67+
}
68+
69+
TSMGetParams that = (TSMGetParams) o;
70+
return latest == that.latest && withLabels == that.withLabels &&
71+
Arrays.equals(selectedLabels, that.selectedLabels);
72+
}
73+
74+
@Override
75+
public int hashCode() {
76+
int result = Boolean.hashCode(latest);
77+
result = 31 * result + Boolean.hashCode(withLabels);
78+
result = 31 * result + Arrays.hashCode(selectedLabels);
79+
return result;
80+
}
5881
}

src/main/java/redis/clients/jedis/timeseries/TSMRangeParams.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import static redis.clients.jedis.timeseries.TimeSeriesProtocol.TimeSeriesKeyword.*;
88
import static redis.clients.jedis.util.SafeEncoder.encode;
99

10+
import java.util.Arrays;
11+
import java.util.Objects;
1012
import redis.clients.jedis.CommandArguments;
1113
import redis.clients.jedis.params.IParams;
1214

@@ -260,4 +262,50 @@ public void addParams(CommandArguments args) {
260262
args.add(GROUPBY).add(groupByLabel).add(REDUCE).add(groupByReduce);
261263
}
262264
}
265+
266+
@Override
267+
public boolean equals(Object o) {
268+
if (this == o) {
269+
return true;
270+
}
271+
if (o == null || getClass() != o.getClass()) {
272+
return false;
273+
}
274+
275+
TSMRangeParams that = (TSMRangeParams) o;
276+
return latest == that.latest && withLabels == that.withLabels &&
277+
bucketDuration == that.bucketDuration && empty == that.empty &&
278+
Objects.equals(fromTimestamp, that.fromTimestamp) &&
279+
Objects.equals(toTimestamp, that.toTimestamp) &&
280+
Arrays.equals(filterByTimestamps, that.filterByTimestamps) &&
281+
Arrays.equals(filterByValues, that.filterByValues) &&
282+
Arrays.equals(selectedLabels, that.selectedLabels) &&
283+
Objects.equals(count, that.count) && Arrays.equals(align, that.align) &&
284+
aggregationType == that.aggregationType &&
285+
Arrays.equals(bucketTimestamp, that.bucketTimestamp) &&
286+
Arrays.equals(filters, that.filters) &&
287+
Objects.equals(groupByLabel, that.groupByLabel) &&
288+
Objects.equals(groupByReduce, that.groupByReduce);
289+
}
290+
291+
@Override
292+
public int hashCode() {
293+
int result = Objects.hashCode(fromTimestamp);
294+
result = 31 * result + Objects.hashCode(toTimestamp);
295+
result = 31 * result + Boolean.hashCode(latest);
296+
result = 31 * result + Arrays.hashCode(filterByTimestamps);
297+
result = 31 * result + Arrays.hashCode(filterByValues);
298+
result = 31 * result + Boolean.hashCode(withLabels);
299+
result = 31 * result + Arrays.hashCode(selectedLabels);
300+
result = 31 * result + Objects.hashCode(count);
301+
result = 31 * result + Arrays.hashCode(align);
302+
result = 31 * result + Objects.hashCode(aggregationType);
303+
result = 31 * result + Long.hashCode(bucketDuration);
304+
result = 31 * result + Arrays.hashCode(bucketTimestamp);
305+
result = 31 * result + Boolean.hashCode(empty);
306+
result = 31 * result + Arrays.hashCode(filters);
307+
result = 31 * result + Objects.hashCode(groupByLabel);
308+
result = 31 * result + Objects.hashCode(groupByReduce);
309+
return result;
310+
}
263311
}

src/main/java/redis/clients/jedis/timeseries/TSRangeParams.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import static redis.clients.jedis.timeseries.TimeSeriesProtocol.TimeSeriesKeyword.*;
88
import static redis.clients.jedis.util.SafeEncoder.encode;
99

10+
import java.util.Arrays;
11+
import java.util.Objects;
1012
import redis.clients.jedis.CommandArguments;
1113
import redis.clients.jedis.params.IParams;
1214

@@ -205,4 +207,40 @@ public void addParams(CommandArguments args) {
205207
}
206208
}
207209
}
210+
211+
@Override
212+
public boolean equals(Object o) {
213+
if (this == o) {
214+
return true;
215+
}
216+
if (o == null || getClass() != o.getClass()) {
217+
return false;
218+
}
219+
220+
TSRangeParams that = (TSRangeParams) o;
221+
return latest == that.latest && bucketDuration == that.bucketDuration && empty == that.empty &&
222+
Objects.equals(fromTimestamp, that.fromTimestamp) &&
223+
Objects.equals(toTimestamp, that.toTimestamp) &&
224+
Arrays.equals(filterByTimestamps, that.filterByTimestamps) &&
225+
Arrays.equals(filterByValues, that.filterByValues) &&
226+
Objects.equals(count, that.count) && Arrays.equals(align, that.align) &&
227+
aggregationType == that.aggregationType &&
228+
Arrays.equals(bucketTimestamp, that.bucketTimestamp);
229+
}
230+
231+
@Override
232+
public int hashCode() {
233+
int result = Objects.hashCode(fromTimestamp);
234+
result = 31 * result + Objects.hashCode(toTimestamp);
235+
result = 31 * result + Boolean.hashCode(latest);
236+
result = 31 * result + Arrays.hashCode(filterByTimestamps);
237+
result = 31 * result + Arrays.hashCode(filterByValues);
238+
result = 31 * result + Objects.hashCode(count);
239+
result = 31 * result + Arrays.hashCode(align);
240+
result = 31 * result + Objects.hashCode(aggregationType);
241+
result = 31 * result + Long.hashCode(bucketDuration);
242+
result = 31 * result + Arrays.hashCode(bucketTimestamp);
243+
result = 31 * result + Boolean.hashCode(empty);
244+
return result;
245+
}
208246
}

0 commit comments

Comments
 (0)