From a5fee01354b9b71da28d6d0c55a0b052cb6469e5 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Mon, 5 Jul 2010 21:32:28 +0000 Subject: [PATCH] Maybe I can generalize this into a rule: if either of operands 2 or 3 to the ternary operator are boolean constants, don't use the ternary operator. a ? true : x == a || x a ? x : true == !a || x a ? false : x == !a && x a ? x : false == a && x --- src/java/com/samskivert/depot/tests/TransformTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/java/com/samskivert/depot/tests/TransformTest.java b/src/java/com/samskivert/depot/tests/TransformTest.java index 4274f56..07d67e8 100644 --- a/src/java/com/samskivert/depot/tests/TransformTest.java +++ b/src/java/com/samskivert/depot/tests/TransformTest.java @@ -54,8 +54,7 @@ public class TransformTest extends TestBase } @Override public boolean equals (Object other) { - return !(other instanceof CustomType) ? false : - value.equals(((CustomType)other).value); + return (other instanceof CustomType) && value.equals(((CustomType)other).value); } @Override public int hashCode () {