Checkstyle complains about the following:
return (null == a ? a : new A());
and says the parens are unnecessary.
While the statement certainly works fine without them, it seems far more readable with them present---otherwise as I'm reading it I tend to see:
return null
first and then have to pause to consider the remaining
== a ? a : new A();
part, since my brain has already gone down one path.
Furthermore, I tend to do the same thing whenever I see a ternary operator, unless it is grouped in parens.
So: should parens around the ternary be the de facto standard? Is there ever any reason to not put them there?
Well, checkstyle is right, the parentheses are useless for the execution. But useless for the execution doesn't mean useless for the good reading of your code. You should leave them if it makes more sense to read.
I think this code doesn't need more parentheses:
int number = (myBoolean)? 1 : 2;
but in your case the return
keyword and the fact your boolean is an expression can change the way you read the statement.