Ramjay Romorosa
Ramjay Romorosa

Reputation: 317

How can I simplify this boolean literals wrapped into if-then-else into a single invocation to conform to sonarqube. Thanks

@Override
protected boolean willFlightBeChanged(AwbFlt awbFlt) {
    if (CargoMaxUtil.isHostCarrier(awbFlt.carrier()) && (!Str.equals(awbFlt.alloc, AwbFlt.ALLOC_UU)))
        return true;
    return false;
}

Upvotes: 1

Views: 68

Answers (1)

Andy Turner
Andy Turner

Reputation: 140329

In general:

if (condition)
  return true;
return false;

is exactly the same as:

return condition;

So:

return CargoMaxUtil.isHostCarrier(awbFlt.carrier()) && (!Str.equals(awbFlt.alloc, AwbFlt.ALLOC_UU));

Upvotes: 1

Related Questions