Skip to content

Commit d307d04

Browse files
committed
#192: Remvove 'obj == this' from equals methods.
Signed-off-by: Franz Wilhelmstötter <franz.wilhelmstoetter@gmail.com>
1 parent eb90d8e commit d307d04

File tree

17 files changed

+17
-34
lines changed

17 files changed

+17
-34
lines changed

jpx/src/main/java/io/jenetics/jpx/Bounds.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ public int hashCode() {
117117

118118
@Override
119119
public boolean equals(final Object obj) {
120-
return obj == this ||
121-
obj instanceof Bounds bounds &&
120+
return obj instanceof Bounds bounds &&
122121
Objects.equals(bounds._minLatitude, _minLatitude) &&
123122
Objects.equals(bounds._minLongitude, _minLongitude) &&
124123
Objects.equals(bounds._maxLatitude, _maxLatitude) &&
@@ -140,7 +139,6 @@ public String toString() {
140139
* Return a collector which calculates the bounds of a given way-point
141140
* stream. The following example shows how to calculate the bounds of all
142141
* track-points of a given GPX object.
143-
*
144142
* {@snippet lang="java":
145143
* final Bounds bounds = gpx.tracks()
146144
* .flatMap(Track::segments)

jpx/src/main/java/io/jenetics/jpx/Copyright.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ public int hashCode() {
103103

104104
@Override
105105
public boolean equals(final Object obj) {
106-
return obj == this ||
107-
obj instanceof Copyright cr &&
106+
return obj instanceof Copyright cr &&
108107
Objects.equals(cr._author, _author) &&
109108
Objects.equals(cr._year, _year) &&
110109
Objects.equals(cr._license, _license);

jpx/src/main/java/io/jenetics/jpx/DGPSStation.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ public int hashCode() {
120120

121121
@Override
122122
public boolean equals(final Object obj) {
123-
return obj == this ||
124-
obj instanceof DGPSStation dgps &&
123+
return obj instanceof DGPSStation dgps &&
125124
dgps._value == _value;
126125
}
127126

jpx/src/main/java/io/jenetics/jpx/Email.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ public int hashCode() {
105105

106106
@Override
107107
public boolean equals(final Object obj) {
108-
return obj == this ||
109-
obj instanceof Email email &&
108+
return obj instanceof Email email &&
110109
Objects.equals(email._id, _id) &&
111110
Objects.equals(email._domain, _domain);
112111
}

jpx/src/main/java/io/jenetics/jpx/GPX.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,7 @@ public int hashCode() {
472472

473473
@Override
474474
public boolean equals(final Object obj) {
475-
return obj == this ||
476-
obj instanceof GPX gpx &&
475+
return obj instanceof GPX gpx &&
477476
Objects.equals(gpx._creator, _creator) &&
478477
Objects.equals(gpx._version, _version) &&
479478
Objects.equals(gpx._metadata, _metadata) &&

jpx/src/main/java/io/jenetics/jpx/Length.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ public int hashCode() {
192192

193193
@Override
194194
public boolean equals(final Object obj) {
195-
return obj == this ||
196-
obj instanceof Length lng &&
195+
return obj instanceof Length lng &&
197196
Double.compare(lng._value, _value) == 0;
198197
}
199198

jpx/src/main/java/io/jenetics/jpx/Link.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ public int hashCode() {
101101

102102
@Override
103103
public boolean equals(final Object obj) {
104-
return obj == this ||
105-
obj instanceof Link link &&
104+
return obj instanceof Link link &&
106105
Objects.equals(link._href, _href) &&
107106
Objects.equals(link._text, _text) &&
108107
Objects.equals(link._type, _type);

jpx/src/main/java/io/jenetics/jpx/Metadata.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,7 @@ public int hashCode() {
270270

271271
@Override
272272
public boolean equals(final Object obj) {
273-
return obj == this ||
274-
obj instanceof Metadata meta &&
273+
return obj instanceof Metadata meta &&
275274
Objects.equals(meta._name, _name) &&
276275
Objects.equals(meta._description, _description) &&
277276
Objects.equals(meta._author, _author) &&

jpx/src/main/java/io/jenetics/jpx/NonNullList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public int hashCode() {
292292

293293
@Override
294294
public boolean equals(final Object o) {
295-
return o == this || _adoptee.equals(o);
295+
return o instanceof List<?> list && _adoptee.equals(list);
296296
}
297297

298298
}

jpx/src/main/java/io/jenetics/jpx/Person.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ public int hashCode() {
116116

117117
@Override
118118
public boolean equals(final Object obj) {
119-
return obj == this ||
120-
obj instanceof Person person &&
119+
return obj instanceof Person person &&
121120
Objects.equals(person._name, _name) &&
122121
Objects.equals(person._email, _email) &&
123122
Objects.equals(person._link, _link);

0 commit comments

Comments
 (0)