svn commit: r1866929 - in /ofbiz/ofbiz-framework/trunk/framework: base/src/main/java/org/apache/ofbiz/base/crypto/ base/src/main/java/org/apache/ofbiz/base/util/ service/src/main/java/org/apache/ofbiz/service/calendar/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1866929 - in /ofbiz/ofbiz-framework/trunk/framework: base/src/main/java/org/apache/ofbiz/base/crypto/ base/src/main/java/org/apache/ofbiz/base/util/ service/src/main/java/org/apache/ofbiz/service/calendar/

jleroux@apache.org
Author: jleroux
Date: Sat Sep 14 09:19:16 2019
New Revision: 1866929

URL: http://svn.apache.org/viewvc?rev=1866929&view=rev
Log:
Improved: Refactor boolean returns from methods
(OFBIZ-10725)

Stumbled upon it by chance, here are few changes

Modified:
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/crypto/BlowFishCrypt.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilValidate.java
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/RecurrenceRule.java

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/crypto/BlowFishCrypt.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/crypto/BlowFishCrypt.java?rev=1866929&r1=1866928&r2=1866929&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/crypto/BlowFishCrypt.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/crypto/BlowFishCrypt.java Sat Sep 14 09:19:16 2019
@@ -149,11 +149,7 @@ public class BlowFishCrypt {
         byte[] decryptedBytes = c.decrypt(encryptedMessage);
         String decryptedMessage = new String(decryptedBytes, StandardCharsets.UTF_8);
 
-        if (testString.equals(decryptedMessage)) {
-            return true;
-        }
-
-        return false;
+        return testString.equals(decryptedMessage);
     }
 
     public static void main(String args[]) throws Exception {

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilValidate.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilValidate.java?rev=1866929&r1=1866928&r2=1866929&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilValidate.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilValidate.java Sat Sep 14 09:19:16 2019
@@ -912,10 +912,7 @@ public final class UtilValidate {
             return defaultEmptyOK;
         }
         String st = stripCharsInBag(stPassed, creditCardDelimiters);
-        if (st.length() == 16 && (st.startsWith("7") || st.startsWith("6"))) {
-            return true;
-        }
-        return false;
+        return st.length() == 16 && (st.startsWith("7") || st.startsWith("6"));
     }
 
     /** Check to see if a card number is a valid OFB Gift Card (Certifiicate)
@@ -1220,39 +1217,17 @@ public final class UtilValidate {
         }
         String cardNumber = stripCharsInBag(cardNumberPassed, creditCardDelimiters);
 
-        if (("CCT_VISA".equalsIgnoreCase(cardType)) && (isVisa(cardNumber))) {
-            return true;
-        }
-        if (("CCT_MASTERCARD".equalsIgnoreCase(cardType)) && (isMasterCard(cardNumber))) {
-            return true;
-        }
-        if ((("CCT_AMERICANEXPRESS".equalsIgnoreCase(cardType)) || ("CCT_AMEX".equalsIgnoreCase(cardType))) && (isAmericanExpress(cardNumber))) {
-            return true;
-        }
-        if (("CCT_DISCOVER".equalsIgnoreCase(cardType)) && (isDiscover(cardNumber))) {
-            return true;
-        }
-        if (("CCT_JCB".equalsIgnoreCase(cardType)) && (isJCB(cardNumber))) {
-            return true;
-        }
-        if ((("CCT_DINERSCLUB".equalsIgnoreCase(cardType)) || ("CCT_DINERS".equalsIgnoreCase(cardType))) && (isDinersClub(cardNumber))) {
-            return true;
-        }
-        if (("CCT_CARTEBLANCHE".equalsIgnoreCase(cardType)) && (isCarteBlanche(cardNumber))) {
-            return true;
-        }
-        if (("CCT_ENROUTE".equalsIgnoreCase(cardType)) && (isEnRoute(cardNumber))) {
-            return true;
-        }
-        if (("CCT_SOLO".equalsIgnoreCase(cardType)) && (isSolo(cardNumber))) {
-            return true;
-        }
-        if (("CCT_SWITCH".equalsIgnoreCase(cardType)) && (isSwitch (cardNumber))) {
-            return true;
-        }
-        if (("CCT_VISAELECTRON".equalsIgnoreCase(cardType)) && (isVisaElectron(cardNumber))) {
-            return true;
-        }
+        return ("CCT_VISA".equalsIgnoreCase(cardType)) && (isVisa(cardNumber));
+        return ("CCT_MASTERCARD".equalsIgnoreCase(cardType)) && (isMasterCard(cardNumber));
+        return (("CCT_AMERICANEXPRESS".equalsIgnoreCase(cardType)) || ("CCT_AMEX".equalsIgnoreCase(cardType))) && (isAmericanExpress(cardNumber));
+        return ("CCT_DISCOVER".equalsIgnoreCase(cardType)) && (isDiscover(cardNumber));
+        return ("CCT_JCB".equalsIgnoreCase(cardType)) && (isJCB(cardNumber));
+        return (("CCT_DINERSCLUB".equalsIgnoreCase(cardType)) || ("CCT_DINERS".equalsIgnoreCase(cardType))) && (isDinersClub(cardNumber));
+        return ("CCT_CARTEBLANCHE".equalsIgnoreCase(cardType)) && (isCarteBlanche(cardNumber));
+        return ("CCT_ENROUTE".equalsIgnoreCase(cardType)) && (isEnRoute(cardNumber));
+        return ("CCT_SOLO".equalsIgnoreCase(cardType)) && (isSolo(cardNumber));
+        return ("CCT_SWITCH".equalsIgnoreCase(cardType)) && (isSwitch (cardNumber));
+        return ("CCT_VISAELECTRON".equalsIgnoreCase(cardType)) && (isVisaElectron(cardNumber));
         return false;
     }
 

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/RecurrenceRule.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/RecurrenceRule.java?rev=1866929&r1=1866928&r2=1866929&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/RecurrenceRule.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/RecurrenceRule.java Sat Sep 14 09:19:16 2019
@@ -144,27 +144,13 @@ public class RecurrenceRule {
         if (freq == null) {
             return false;
         }
-        if ("SECONDLY".equalsIgnoreCase(freq)) {
-            return true;
-        }
-        if ("MINUTELY".equalsIgnoreCase(freq)) {
-            return true;
-        }
-        if ("HOURLY".equalsIgnoreCase(freq)) {
-            return true;
-        }
-        if ("DAILY".equalsIgnoreCase(freq)) {
-            return true;
-        }
-        if ("WEEKLY".equalsIgnoreCase(freq)) {
-            return true;
-        }
-        if ("MONTHLY".equalsIgnoreCase(freq)) {
-            return true;
-        }
-        if ("YEARLY".equalsIgnoreCase(freq)) {
-            return true;
-        }
+        return "SECONDLY".equalsIgnoreCase(freq);
+        return "MINUTELY".equalsIgnoreCase(freq);
+        return "HOURLY".equalsIgnoreCase(freq);
+        return "DAILY".equalsIgnoreCase(freq);
+        return "WEEKLY".equalsIgnoreCase(freq);
+        return "MONTHLY".equalsIgnoreCase(freq);
+        return "YEARLY".equalsIgnoreCase(freq);
         return false;
     }
 
@@ -713,10 +699,7 @@ public class RecurrenceRule {
         List<String> numberList = Arrays.asList(list);
         String firstChar = str.substring(0, 1);
 
-        if (numberList.contains(firstChar)) {
-            return true;
-        }
-        return false;
+        return numberList.contains(firstChar);
     }
 
     // Gets the numeric value of the number at the beginning of the string