Author: adityasharma
Date: Thu Jan 3 08:51:14 2019 New Revision: 1850223 URL: http://svn.apache.org/viewvc?rev=1850223&view=rev Log: Improved: Refactor boolean returns from methods (OFBIZ-10725) Improved boolean returns with a single statement, replacing if blocks with the explicit boolean return. Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoConfigUtil.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/DateRange.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/MessageString.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilXml.java Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoConfigUtil.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoConfigUtil.java?rev=1850223&r1=1850222&r2=1850223&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoConfigUtil.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoConfigUtil.java Thu Jan 3 08:51:14 2019 @@ -391,11 +391,7 @@ public final class SeoConfigUtil { contextPath = "/"; } if (categoryUrlEnabled) { - if (allowedContextPaths.contains(contextPath.trim())) { - return true; - } else { - return false; - } + return allowedContextPaths.contains(contextPath.trim()); } return false; } Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/DateRange.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/DateRange.java?rev=1850223&r1=1850222&r2=1850223&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/DateRange.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/DateRange.java Thu Jan 3 08:51:14 2019 @@ -107,10 +107,7 @@ public class DateRange extends Comparabl * @return <code>true</code> if <code>range</code> intersects this range */ public boolean intersectsRange(DateRange range) { - if (isPoint() && range.isPoint() && this.start.equals(range.start)) { - return true; - } - return !before(range) && !after(range); + return (isPoint() && range.isPoint() && this.start.equals(range.start)) || (!before(range) && !after(range)); } @Override Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/MessageString.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/MessageString.java?rev=1850223&r1=1850222&r2=1850223&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/MessageString.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/MessageString.java Thu Jan 3 08:51:14 2019 @@ -151,17 +151,11 @@ public class MessageString implements Se this.fieldName = fieldName; } public boolean isForField(Set<String> fieldNameSet) { - if (fieldNameSet == null) { - return true; - } - return fieldNameSet.contains(this.fieldName); + return fieldNameSet == null || fieldNameSet.contains(this.fieldName); } public boolean isForField(String fieldName) { if (this.fieldName == null) { - if (fieldName == null) { - return true; - } - return false; + return fieldName == null; } return this.fieldName.equals(fieldName); } Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java?rev=1850223&r1=1850222&r2=1850223&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java Thu Jan 3 08:51:14 2019 @@ -611,15 +611,9 @@ public class ObjectType { if (value1 == null) { // some default behavior for null values, results in a bit cleaner operation - if ("is-null".equals(operator)) { + if ("is-null".equals(operator) || "is-empty".equals(operator)) { return Boolean.TRUE; - } else if ("is-not-null".equals(operator)) { - return Boolean.FALSE; - } else if ("is-empty".equals(operator)) { - return Boolean.TRUE; - } else if ("is-not-empty".equals(operator)) { - return Boolean.FALSE; - } else if ("contains".equals(operator)) { + } else if ("is-not-null".equals(operator) || "is-not-empty".equals(operator) || "contains".equals(operator)) { return Boolean.FALSE; } } @@ -883,11 +877,8 @@ public class ObjectType { @Override public boolean equals(Object other) { - if (other instanceof NullObject) { // should do equality of object? don't think so, just same type - return true; - } - return false; + return other instanceof NullObject; } } } Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java?rev=1850223&r1=1850222&r2=1850223&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java Thu Jan 3 08:51:14 2019 @@ -370,11 +370,7 @@ public final class UtilProperties implem */ public static boolean propertyValueEquals(URL url, String name, String compareString) { String value = getPropertyValue(url, name); - - if (value == null) { - return false; - } - return value.trim().equals(compareString); + return !(value == null) && value.trim().equals(compareString); } /** Compares Ignoring Case the specified property to the compareString, returns true if they are the same, false otherwise @@ -385,11 +381,7 @@ public final class UtilProperties implem */ public static boolean propertyValueEqualsIgnoreCase(URL url, String name, String compareString) { String value = getPropertyValue(url, name); - - if (value == null) { - return false; - } - return value.trim().equalsIgnoreCase(compareString); + return !(value == null) && value.trim().equalsIgnoreCase(compareString); } /** Returns the value of the specified property name from the specified resource/properties file. Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilXml.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilXml.java?rev=1850223&r1=1850222&r2=1850223&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilXml.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilXml.java Thu Jan 3 08:51:14 2019 @@ -1184,10 +1184,7 @@ public final class UtilXml { @Override public boolean canConvert(@SuppressWarnings("rawtypes") Class arg0) { - if (java.lang.ProcessBuilder.class.equals(arg0)) { - return true; - } - return false; + return java.lang.ProcessBuilder.class.equals(arg0); } @Override |
Free forum by Nabble | Edit this page |