我發現一個方法等於比較兩個移動,我想簡化它。簡化Java布爾比較
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Move other = (Move) obj;
return !(this.initialBalls != other.initialBalls &&
(this.initialBalls == null || !this.initialBalls.equals(other.initialBalls)))
&& this.direction == other.direction && this.color == other.color;
}
有人有想法嗎?
也許代碼審查的人可以幫助你:http://codereview.stackexchange.com/ –
那return語句是不必要的複雜性。前往CR,我會很樂意提供更簡單的東西。 –
這個問題似乎是脫離主題,因爲它是關於codereview,因此屬於該網站。 –