Author: adityasharma
Date: Sat Dec 22 10:44:12 2018
New Revision: 1849536
URL:
http://svn.apache.org/viewvc?rev=1849536&view=revLog:
Improved: Refactor ServiceUtil.isSuccess(), isError() and isFailure() methods
(OFBIZ-10724)
Improved boolean returns with single statement, replacing if blocks with explicit boolean return.
Thanks Jacques Le Roux for the review.
Modified:
ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java
Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java?rev=1849536&r1=1849535&r2=1849536&view=diff==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java Sat Dec 22 10:44:12 2018
@@ -64,25 +64,18 @@ public final class ServiceUtil {
/** A little short-cut method to check to see if a service returned an error */
public static boolean isError(Map<String, ? extends Object> results) {
- if (results == null || results.get(ModelService.RESPONSE_MESSAGE) == null) {
- return false;
- }
- return ModelService.RESPOND_ERROR.equals(results.get(ModelService.RESPONSE_MESSAGE));
+ return !(results == null || results.get(ModelService.RESPONSE_MESSAGE) == null) &&
+ ModelService.RESPOND_ERROR.equals(results.get(ModelService.RESPONSE_MESSAGE));
}
public static boolean isFailure(Map<String, ? extends Object> results) {
- if (results == null || results.get(ModelService.RESPONSE_MESSAGE) == null) {
- return false;
- }
- return ModelService.RESPOND_FAIL.equals(results.get(ModelService.RESPONSE_MESSAGE));
+ return !(results == null || results.get(ModelService.RESPONSE_MESSAGE) == null) &&
+ ModelService.RESPOND_FAIL.equals(results.get(ModelService.RESPONSE_MESSAGE));
}
/** A little short-cut method to check to see if a service was successful (neither error or failed) */
public static boolean isSuccess(Map<String, ? extends Object> results) {
- if (ServiceUtil.isError(results) || ServiceUtil.isFailure(results)) {
- return false;
- }
- return true;
+ return !(ServiceUtil.isError(results) || ServiceUtil.isFailure(results));
}
/** A small routine used all over to improve code efficiency, make a result map with the message and the error response code */