Replace this if-then-else statement by a single return statement

前端 未结 6 1196
天命终不由人
天命终不由人 2020-12-21 01:13

While solving sonarQube issue i face the below warning,does any one tell me how to overcome this warning

Method:-

@Override
    public boolean equals         


        
6条回答
  •  生来不讨喜
    2020-12-21 01:21

    Try something like this:

    return null != obj && this == obj || getClass() == obj.getClass() &&
           this.divisionId == ((Division) obj).divisionId;
    

提交回复
热议问题