From 2e9a359fb59bfd4fc3734bb81d689da7d7d2c0e7 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Fri, 27 Jun 2014 12:55:51 +0000 Subject: [PATCH] Simplify using ternary expressions. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1606075 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/commons/lang3/Conversion.java | 40 ++++--------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/Conversion.java b/src/main/java/org/apache/commons/lang3/Conversion.java index 2980a4fff..bb9927da2 100644 --- a/src/main/java/org/apache/commons/lang3/Conversion.java +++ b/src/main/java/org/apache/commons/lang3/Conversion.java @@ -324,49 +324,25 @@ public class Conversion { if (src.length > srcPos + 3 && src[srcPos + 3]) { if (src.length > srcPos + 2 && src[srcPos + 2]) { if (src.length > srcPos + 1 && src[srcPos + 1]) { - if (src[srcPos]) { - return 'f'; - } - return 'e'; + return src[srcPos] ? 'f' : 'e'; } - if (src[srcPos]) { - return 'd'; - } - return 'c'; + return src[srcPos] ? 'd' : 'c'; } if (src.length > srcPos + 1 && src[srcPos + 1]) { - if (src[srcPos]) { - return 'b'; - } - return 'a'; + return src[srcPos] ? 'b' : 'a'; } - if (src[srcPos]) { - return '9'; - } - return '8'; + return src[srcPos] ? '9' : '8'; } if (src.length > srcPos + 2 && src[srcPos + 2]) { if (src.length > srcPos + 1 && src[srcPos + 1]) { - if (src[srcPos]) { - return '7'; - } - return '6'; + return src[srcPos] ? '7' : '6'; } - if (src[srcPos]) { - return '5'; - } - return '4'; + return src[srcPos] ? '5' : '4'; } if (src.length > srcPos + 1 && src[srcPos + 1]) { - if (src[srcPos]) { - return '3'; - } - return '2'; + return src[srcPos] ? '3' : '2'; } - if (src[srcPos]) { - return '1'; - } - return '0'; + return src[srcPos] ? '1' : '0'; } /**