Skip to content

Commit fdaed5a

Browse files
committed
string fix and equals fix
1 parent 3c6b1f5 commit fdaed5a

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

src/main/java/bwapi/Client.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ String eventString(final int s) {
124124

125125
int addString(final String s) {
126126
int stringCount = data.getStringCount();
127-
if (stringCount >= MAX_COUNT) throw new IllegalStateException("Too many shapes!");
127+
if (stringCount >= MAX_COUNT) throw new IllegalStateException("Too many strings!");
128128
data.setStringCount(stringCount + 1);
129129
data.setStrings(stringCount, s);
130130
return stringCount;

src/main/java/bwapi/Pair.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ public String toString() {
5252
}
5353

5454
@Override
55-
public boolean equals(final Object o) {
56-
if (o instanceof Pair) {
57-
final Pair op = (Pair)o;
58-
return first.equals(op.first) && second.equals(op.second);
59-
}
60-
return false;
55+
public boolean equals(Object o) {
56+
if (this == o) return true;
57+
if (o == null || getClass() != o.getClass()) return false;
58+
Pair pair = (Pair) o;
59+
return Objects.equals(first, pair.first) &&
60+
Objects.equals(second, pair.second);
6161
}
6262

6363
@Override

src/main/java/bwapi/Point.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ public int getApproxDistance(final Point point) {
5757
}
5858

5959

60-
public boolean equals(final Object o) {
61-
if (o != null && this.getClass().equals(o.getClass())) {
62-
final Point point = (Point) o;
63-
return x == point.x && y == point.y;
64-
}
65-
return false;
66-
60+
@Override
61+
public boolean equals(Object o) {
62+
if (this == o) return true;
63+
if (o == null || getClass() != o.getClass()) return false;
64+
Point point = (Point) o;
65+
return x == point.x &&
66+
y == point.y;
6767
}
6868

6969
/**
@@ -75,6 +75,7 @@ public boolean isValid(final Game game) {
7575
scalar * y < game.mapPixelHeight();
7676
}
7777

78+
@Override
7879
public int hashCode() {
7980
return (x << 16) ^ y;
8081
}

0 commit comments

Comments
 (0)