Improved: Refactor boolean returns from methods

(OFBIZ-10725)
Improved boolean returns with a single statement, replacing if blocks with the explicit boolean return.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1850223 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Aditya Sharma
2019-01-03 08:51:14 +00:00
parent 78e67432e7
commit 5da4f7cd5e
6 changed files with 10 additions and 43 deletions
@@ -107,10 +107,7 @@ public class DateRange extends ComparableRange<Date> implements Serializable {
* @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
@@ -151,17 +151,11 @@ public class MessageString implements Serializable {
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);
}
@@ -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;
}
}
}
@@ -370,11 +370,7 @@ public final class UtilProperties implements Serializable {
*/
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 implements Serializable {
*/
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.
@@ -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