Skip to content

Commit 26efcfc

Browse files
author
jasciiz
committed
for issue: iluwatar#584
Pull request description It.s seems the equal() method in the abstract class isn't designed properly and I make some change in these abstract classes and their subclasses. for issue: iluwatar#584
1 parent e68beb4 commit 26efcfc

File tree

9 files changed

+9
-33
lines changed

9 files changed

+9
-33
lines changed

prototype/src/main/java/com/iluwatar/prototype/Beast.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ public Beast(Beast source) {
3838
public abstract Beast copy();
3939

4040
@Override
41-
public boolean equals(Object obj) {
42-
if (this == obj) {
43-
return true;
44-
}
45-
if (obj == null) {
46-
return false;
47-
}
48-
return getClass() == obj.getClass();
49-
}
41+
public abstract boolean equals(Object obj);
5042

5143
}

prototype/src/main/java/com/iluwatar/prototype/ElfBeast.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public boolean equals(Object obj) {
5454
if (this == obj) {
5555
return true;
5656
}
57-
if (!super.equals(obj)) {
57+
if (obj ==null) {
5858
return false;
5959
}
6060
if (getClass() != obj.getClass()) {

prototype/src/main/java/com/iluwatar/prototype/ElfMage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public boolean equals(Object obj) {
5454
if (this == obj) {
5555
return true;
5656
}
57-
if (!super.equals(obj)) {
57+
if (obj ==null) {
5858
return false;
5959
}
6060
if (getClass() != obj.getClass()) {

prototype/src/main/java/com/iluwatar/prototype/ElfWarlord.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public boolean equals(Object obj) {
5454
if (this == obj) {
5555
return true;
5656
}
57-
if (!super.equals(obj)) {
57+
if (obj ==null) {
5858
return false;
5959
}
6060
if (getClass() != obj.getClass()) {

prototype/src/main/java/com/iluwatar/prototype/Mage.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ public Mage(Mage source) {
3838
public abstract Mage copy();
3939

4040
@Override
41-
public boolean equals(Object obj) {
42-
if (this == obj) {
43-
return true;
44-
}
45-
if (obj == null) {
46-
return false;
47-
}
48-
return getClass() == obj.getClass();
49-
}
41+
public abstract boolean equals(Object obj);
5042

5143
}

prototype/src/main/java/com/iluwatar/prototype/OrcBeast.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public boolean equals(Object obj) {
5454
if (this == obj) {
5555
return true;
5656
}
57-
if (!super.equals(obj)) {
57+
if (obj ==null) {
5858
return false;
5959
}
6060
if (getClass() != obj.getClass()) {

prototype/src/main/java/com/iluwatar/prototype/OrcMage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public boolean equals(Object obj) {
5454
if (this == obj) {
5555
return true;
5656
}
57-
if (!super.equals(obj)) {
57+
if (obj ==null) {
5858
return false;
5959
}
6060
if (getClass() != obj.getClass()) {

prototype/src/main/java/com/iluwatar/prototype/OrcWarlord.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public boolean equals(Object obj) {
5454
if (this == obj) {
5555
return true;
5656
}
57-
if (!super.equals(obj)) {
57+
if (obj ==null) {
5858
return false;
5959
}
6060
if (getClass() != obj.getClass()) {

prototype/src/main/java/com/iluwatar/prototype/Warlord.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ public Warlord(Warlord source) {
3838
public abstract Warlord copy();
3939

4040
@Override
41-
public boolean equals(Object obj) {
42-
if (this == obj) {
43-
return true;
44-
}
45-
if (obj == null) {
46-
return false;
47-
}
48-
return getClass() == obj.getClass();
49-
}
41+
public abstract boolean equals(Object obj);
5042

5143
}

0 commit comments

Comments
 (0)