我发现一个方法等于比较两个移动,我想简化它。简化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,因此属于该网站。 –