Skip to content

Commit

Permalink
Add equals and hashCode to Timeseries Params classes (#3959)
Browse files Browse the repository at this point in the history
  • Loading branch information
ascdi authored Sep 22, 2024
1 parent 2229a34 commit 1effa7a
Show file tree
Hide file tree
Showing 8 changed files with 254 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/main/java/redis/clients/jedis/timeseries/TSAddParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import redis.clients.jedis.CommandArguments;
import redis.clients.jedis.params.IParams;

Expand Down Expand Up @@ -125,4 +126,36 @@ public void addParams(CommandArguments args) {
labels.entrySet().forEach((entry) -> args.add(entry.getKey()).add(entry.getValue()));
}
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

TSAddParams that = (TSAddParams) o;
return ignore == that.ignore && ignoreMaxTimediff == that.ignoreMaxTimediff &&
Double.compare(ignoreMaxValDiff, that.ignoreMaxValDiff) == 0 &&
Objects.equals(retentionPeriod, that.retentionPeriod) &&
encoding == that.encoding && Objects.equals(chunkSize, that.chunkSize) &&
duplicatePolicy == that.duplicatePolicy && onDuplicate == that.onDuplicate &&
Objects.equals(labels, that.labels);
}

@Override
public int hashCode() {
int result = Objects.hashCode(retentionPeriod);
result = 31 * result + Objects.hashCode(encoding);
result = 31 * result + Objects.hashCode(chunkSize);
result = 31 * result + Objects.hashCode(duplicatePolicy);
result = 31 * result + Objects.hashCode(onDuplicate);
result = 31 * result + Boolean.hashCode(ignore);
result = 31 * result + Long.hashCode(ignoreMaxTimediff);
result = 31 * result + Double.hashCode(ignoreMaxValDiff);
result = 31 * result + Objects.hashCode(labels);
return result;
}
}
30 changes: 30 additions & 0 deletions src/main/java/redis/clients/jedis/timeseries/TSAlterParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import redis.clients.jedis.CommandArguments;
import redis.clients.jedis.params.IParams;

Expand Down Expand Up @@ -106,4 +107,33 @@ public void addParams(CommandArguments args) {
labels.entrySet().forEach((entry) -> args.add(entry.getKey()).add(entry.getValue()));
}
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

TSAlterParams that = (TSAlterParams) o;
return ignore == that.ignore && ignoreMaxTimediff == that.ignoreMaxTimediff &&
Double.compare(ignoreMaxValDiff, that.ignoreMaxValDiff) == 0 &&
Objects.equals(retentionPeriod, that.retentionPeriod) &&
Objects.equals(chunkSize, that.chunkSize) &&
duplicatePolicy == that.duplicatePolicy && Objects.equals(labels, that.labels);
}

@Override
public int hashCode() {
int result = Objects.hashCode(retentionPeriod);
result = 31 * result + Objects.hashCode(chunkSize);
result = 31 * result + Objects.hashCode(duplicatePolicy);
result = 31 * result + Boolean.hashCode(ignore);
result = 31 * result + Long.hashCode(ignoreMaxTimediff);
result = 31 * result + Double.hashCode(ignoreMaxValDiff);
result = 31 * result + Objects.hashCode(labels);
return result;
}
}
33 changes: 33 additions & 0 deletions src/main/java/redis/clients/jedis/timeseries/TSArithByParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import redis.clients.jedis.CommandArguments;
import redis.clients.jedis.params.IParams;

Expand Down Expand Up @@ -117,4 +118,36 @@ public void addParams(CommandArguments args) {
labels.entrySet().forEach((entry) -> args.add(entry.getKey()).add(entry.getValue()));
}
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

TSArithByParams<?> that = (TSArithByParams<?>) o;
return ignore == that.ignore && ignoreMaxTimediff == that.ignoreMaxTimediff &&
Double.compare(ignoreMaxValDiff, that.ignoreMaxValDiff) == 0 &&
Objects.equals(timestamp, that.timestamp) &&
Objects.equals(retentionPeriod, that.retentionPeriod) &&
encoding == that.encoding && Objects.equals(chunkSize, that.chunkSize) &&
duplicatePolicy == that.duplicatePolicy && Objects.equals(labels, that.labels);
}

@Override
public int hashCode() {
int result = Objects.hashCode(timestamp);
result = 31 * result + Objects.hashCode(retentionPeriod);
result = 31 * result + Objects.hashCode(encoding);
result = 31 * result + Objects.hashCode(chunkSize);
result = 31 * result + Objects.hashCode(duplicatePolicy);
result = 31 * result + Boolean.hashCode(ignore);
result = 31 * result + Long.hashCode(ignoreMaxTimediff);
result = 31 * result + Double.hashCode(ignoreMaxValDiff);
result = 31 * result + Objects.hashCode(labels);
return result;
}
}
31 changes: 31 additions & 0 deletions src/main/java/redis/clients/jedis/timeseries/TSCreateParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import redis.clients.jedis.CommandArguments;
import redis.clients.jedis.params.IParams;

Expand Down Expand Up @@ -121,4 +122,34 @@ public void addParams(CommandArguments args) {
labels.entrySet().forEach((entry) -> args.add(entry.getKey()).add(entry.getValue()));
}
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

TSCreateParams that = (TSCreateParams) o;
return ignore == that.ignore && ignoreMaxTimediff == that.ignoreMaxTimediff &&
Double.compare(ignoreMaxValDiff, that.ignoreMaxValDiff) == 0 &&
Objects.equals(retentionPeriod, that.retentionPeriod) &&
encoding == that.encoding && Objects.equals(chunkSize, that.chunkSize) &&
duplicatePolicy == that.duplicatePolicy && Objects.equals(labels, that.labels);
}

@Override
public int hashCode() {
int result = Objects.hashCode(retentionPeriod);
result = 31 * result + Objects.hashCode(encoding);
result = 31 * result + Objects.hashCode(chunkSize);
result = 31 * result + Objects.hashCode(duplicatePolicy);
result = 31 * result + Boolean.hashCode(ignore);
result = 31 * result + Long.hashCode(ignoreMaxTimediff);
result = 31 * result + Double.hashCode(ignoreMaxValDiff);
result = 31 * result + Objects.hashCode(labels);
return result;
}
}
18 changes: 18 additions & 0 deletions src/main/java/redis/clients/jedis/timeseries/TSGetParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,22 @@ public void addParams(CommandArguments args) {
args.add(LATEST);
}
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

TSGetParams that = (TSGetParams) o;
return latest == that.latest;
}

@Override
public int hashCode() {
return Boolean.hashCode(latest);
}
}
23 changes: 23 additions & 0 deletions src/main/java/redis/clients/jedis/timeseries/TSMGetParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static redis.clients.jedis.timeseries.TimeSeriesProtocol.TimeSeriesKeyword.SELECTED_LABELS;
import static redis.clients.jedis.timeseries.TimeSeriesProtocol.TimeSeriesKeyword.WITHLABELS;

import java.util.Arrays;
import redis.clients.jedis.CommandArguments;
import redis.clients.jedis.params.IParams;

Expand Down Expand Up @@ -55,4 +56,26 @@ public void addParams(CommandArguments args) {
}
}
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

TSMGetParams that = (TSMGetParams) o;
return latest == that.latest && withLabels == that.withLabels &&
Arrays.equals(selectedLabels, that.selectedLabels);
}

@Override
public int hashCode() {
int result = Boolean.hashCode(latest);
result = 31 * result + Boolean.hashCode(withLabels);
result = 31 * result + Arrays.hashCode(selectedLabels);
return result;
}
}
48 changes: 48 additions & 0 deletions src/main/java/redis/clients/jedis/timeseries/TSMRangeParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import static redis.clients.jedis.timeseries.TimeSeriesProtocol.TimeSeriesKeyword.*;
import static redis.clients.jedis.util.SafeEncoder.encode;

import java.util.Arrays;
import java.util.Objects;
import redis.clients.jedis.CommandArguments;
import redis.clients.jedis.params.IParams;

Expand Down Expand Up @@ -260,4 +262,50 @@ public void addParams(CommandArguments args) {
args.add(GROUPBY).add(groupByLabel).add(REDUCE).add(groupByReduce);
}
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

TSMRangeParams that = (TSMRangeParams) o;
return latest == that.latest && withLabels == that.withLabels &&
bucketDuration == that.bucketDuration && empty == that.empty &&
Objects.equals(fromTimestamp, that.fromTimestamp) &&
Objects.equals(toTimestamp, that.toTimestamp) &&
Arrays.equals(filterByTimestamps, that.filterByTimestamps) &&
Arrays.equals(filterByValues, that.filterByValues) &&
Arrays.equals(selectedLabels, that.selectedLabels) &&
Objects.equals(count, that.count) && Arrays.equals(align, that.align) &&
aggregationType == that.aggregationType &&
Arrays.equals(bucketTimestamp, that.bucketTimestamp) &&
Arrays.equals(filters, that.filters) &&
Objects.equals(groupByLabel, that.groupByLabel) &&
Objects.equals(groupByReduce, that.groupByReduce);
}

@Override
public int hashCode() {
int result = Objects.hashCode(fromTimestamp);
result = 31 * result + Objects.hashCode(toTimestamp);
result = 31 * result + Boolean.hashCode(latest);
result = 31 * result + Arrays.hashCode(filterByTimestamps);
result = 31 * result + Arrays.hashCode(filterByValues);
result = 31 * result + Boolean.hashCode(withLabels);
result = 31 * result + Arrays.hashCode(selectedLabels);
result = 31 * result + Objects.hashCode(count);
result = 31 * result + Arrays.hashCode(align);
result = 31 * result + Objects.hashCode(aggregationType);
result = 31 * result + Long.hashCode(bucketDuration);
result = 31 * result + Arrays.hashCode(bucketTimestamp);
result = 31 * result + Boolean.hashCode(empty);
result = 31 * result + Arrays.hashCode(filters);
result = 31 * result + Objects.hashCode(groupByLabel);
result = 31 * result + Objects.hashCode(groupByReduce);
return result;
}
}
38 changes: 38 additions & 0 deletions src/main/java/redis/clients/jedis/timeseries/TSRangeParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import static redis.clients.jedis.timeseries.TimeSeriesProtocol.TimeSeriesKeyword.*;
import static redis.clients.jedis.util.SafeEncoder.encode;

import java.util.Arrays;
import java.util.Objects;
import redis.clients.jedis.CommandArguments;
import redis.clients.jedis.params.IParams;

Expand Down Expand Up @@ -205,4 +207,40 @@ public void addParams(CommandArguments args) {
}
}
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

TSRangeParams that = (TSRangeParams) o;
return latest == that.latest && bucketDuration == that.bucketDuration && empty == that.empty &&
Objects.equals(fromTimestamp, that.fromTimestamp) &&
Objects.equals(toTimestamp, that.toTimestamp) &&
Arrays.equals(filterByTimestamps, that.filterByTimestamps) &&
Arrays.equals(filterByValues, that.filterByValues) &&
Objects.equals(count, that.count) && Arrays.equals(align, that.align) &&
aggregationType == that.aggregationType &&
Arrays.equals(bucketTimestamp, that.bucketTimestamp);
}

@Override
public int hashCode() {
int result = Objects.hashCode(fromTimestamp);
result = 31 * result + Objects.hashCode(toTimestamp);
result = 31 * result + Boolean.hashCode(latest);
result = 31 * result + Arrays.hashCode(filterByTimestamps);
result = 31 * result + Arrays.hashCode(filterByValues);
result = 31 * result + Objects.hashCode(count);
result = 31 * result + Arrays.hashCode(align);
result = 31 * result + Objects.hashCode(aggregationType);
result = 31 * result + Long.hashCode(bucketDuration);
result = 31 * result + Arrays.hashCode(bucketTimestamp);
result = 31 * result + Boolean.hashCode(empty);
return result;
}
}

0 comments on commit 1effa7a

Please sign in to comment.