Skip to content

Commit 2bcb06a

Browse files
committed
DATAREDIS-1143 - Polishing.
Replace delomboked equals/hashCode with Spring-style equals/hashCode. Original pull request: #530.
1 parent 51cba2b commit 2bcb06a

File tree

3 files changed

+48
-52
lines changed

3 files changed

+48
-52
lines changed

Diff for: src/main/java/org/springframework/data/redis/connection/ReactiveRedisConnection.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ class CommandResponse<I, O> {
351351
private final I input;
352352
private final @Nullable O output;
353353

354-
public CommandResponse(I input, O output) {
354+
public CommandResponse(I input, @Nullable O output) {
355355
this.input = input;
356356
this.output = output;
357357
}

Diff for: src/main/java/org/springframework/data/redis/connection/RedisGeoCommands.java

+22-23
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.springframework.data.geo.Point;
2929
import org.springframework.lang.Nullable;
3030
import org.springframework.util.Assert;
31+
import org.springframework.util.ObjectUtils;
3132

3233
/**
3334
* Geo-specific Redis commands.
@@ -370,39 +371,37 @@ public Point getPoint() {
370371
return this.point;
371372
}
372373

373-
public boolean equals(final Object o) {
374-
if (o == this)
374+
@Override
375+
public boolean equals(Object o) {
376+
377+
if (this == o) {
375378
return true;
376-
if (!(o instanceof GeoLocation))
377-
return false;
378-
final GeoLocation<?> other = (GeoLocation<?>) o;
379-
if (!other.canEqual((Object) this))
380-
return false;
381-
final Object this$name = this.getName();
382-
final Object other$name = other.getName();
383-
if (this$name == null ? other$name != null : !this$name.equals(other$name))
379+
}
380+
381+
if (!(o instanceof GeoLocation)) {
384382
return false;
385-
final Object this$point = this.getPoint();
386-
final Object other$point = other.getPoint();
387-
if (this$point == null ? other$point != null : !this$point.equals(other$point))
383+
}
384+
385+
GeoLocation<?> that = (GeoLocation<?>) o;
386+
387+
if (!ObjectUtils.nullSafeEquals(name, that.name)) {
388388
return false;
389-
return true;
390-
}
389+
}
391390

392-
protected boolean canEqual(final Object other) {
393-
return other instanceof GeoLocation;
391+
return ObjectUtils.nullSafeEquals(point, that.point);
394392
}
395393

394+
@Override
396395
public int hashCode() {
397-
final int PRIME = 59;
398-
int result = 1;
399-
final Object $name = this.getName();
400-
result = result * PRIME + ($name == null ? 43 : $name.hashCode());
401-
final Object $point = this.getPoint();
402-
result = result * PRIME + ($point == null ? 43 : $point.hashCode());
396+
int result = ObjectUtils.nullSafeHashCode(name);
397+
result = 31 * result + ObjectUtils.nullSafeHashCode(point);
403398
return result;
404399
}
405400

401+
protected boolean canEqual(Object other) {
402+
return other instanceof GeoLocation;
403+
}
404+
406405
public String toString() {
407406
return "RedisGeoCommands.GeoLocation(name=" + this.getName() + ", point=" + this.getPoint() + ")";
408407
}

Diff for: src/main/java/org/springframework/data/redis/core/convert/GeoIndexedPropertyValue.java

+25-28
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.springframework.data.redis.core.convert;
1717

1818
import org.springframework.data.geo.Point;
19+
import org.springframework.util.ObjectUtils;
1920

2021
/**
2122
* {@link IndexedData} implementation indicating storage of data within a Redis GEO structure.
@@ -73,45 +74,41 @@ public Point getValue() {
7374
return this.value;
7475
}
7576

76-
public boolean equals(final Object o) {
77-
if (o == this)
77+
@Override
78+
public boolean equals(Object o) {
79+
80+
if (this == o) {
7881
return true;
79-
if (!(o instanceof GeoIndexedPropertyValue))
80-
return false;
81-
final GeoIndexedPropertyValue other = (GeoIndexedPropertyValue) o;
82-
if (!other.canEqual((Object) this))
83-
return false;
84-
final Object this$keyspace = this.getKeyspace();
85-
final Object other$keyspace = other.getKeyspace();
86-
if (this$keyspace == null ? other$keyspace != null : !this$keyspace.equals(other$keyspace))
82+
}
83+
84+
if (!(o instanceof GeoIndexedPropertyValue)) {
8785
return false;
88-
final Object this$indexName = this.getIndexName();
89-
final Object other$indexName = other.getIndexName();
90-
if (this$indexName == null ? other$indexName != null : !this$indexName.equals(other$indexName))
86+
}
87+
88+
GeoIndexedPropertyValue that = (GeoIndexedPropertyValue) o;
89+
if (!ObjectUtils.nullSafeEquals(keyspace, that.keyspace)) {
9190
return false;
92-
final Object this$value = this.getValue();
93-
final Object other$value = other.getValue();
94-
if (this$value == null ? other$value != null : !this$value.equals(other$value))
91+
}
92+
93+
if (!ObjectUtils.nullSafeEquals(indexName, that.indexName)) {
9594
return false;
96-
return true;
97-
}
95+
}
9896

99-
protected boolean canEqual(final Object other) {
100-
return other instanceof GeoIndexedPropertyValue;
97+
return ObjectUtils.nullSafeEquals(value, that.value);
10198
}
10299

100+
@Override
103101
public int hashCode() {
104-
final int PRIME = 59;
105-
int result = 1;
106-
final Object $keyspace = this.getKeyspace();
107-
result = result * PRIME + ($keyspace == null ? 43 : $keyspace.hashCode());
108-
final Object $indexName = this.getIndexName();
109-
result = result * PRIME + ($indexName == null ? 43 : $indexName.hashCode());
110-
final Object $value = this.getValue();
111-
result = result * PRIME + ($value == null ? 43 : $value.hashCode());
102+
int result = ObjectUtils.nullSafeHashCode(keyspace);
103+
result = 31 * result + ObjectUtils.nullSafeHashCode(indexName);
104+
result = 31 * result + ObjectUtils.nullSafeHashCode(value);
112105
return result;
113106
}
114107

108+
protected boolean canEqual(Object other) {
109+
return other instanceof GeoIndexedPropertyValue;
110+
}
111+
115112
public String toString() {
116113
return "GeoIndexedPropertyValue(keyspace=" + this.getKeyspace() + ", indexName=" + this.getIndexName() + ", value="
117114
+ this.getValue() + ")";

0 commit comments

Comments
 (0)