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

前端 未结 6 1285
天命终不由人
天命终不由人 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:41

    This must work :

    return this == obj
            ? true
            : obj == null
                ? false 
                : getClass() != obj.getClass()
                    ? false
                    : divisionId != ((Division)obj).divisionId
                        ? false : true
    

提交回复
热议问题