Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-10725 Refactor boolean returns from methods
  3. OFBIZ-10724

Refactor ServiceUtil.isSuccess(), isError() and isFailure() methods

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: Trunk
    • Fix Version/s: Upcoming Branch
    • Component/s: framework
    • Labels:
      None

      Description

      Following lines for isSuccess():

      if (ServiceUtil.isError(results) || ServiceUtil.isFailure(results)) { 
      return false; 
      } 
      return true;
      

      can be changed to

      return !(ServiceUtil.isError(results) || ServiceUtil.isFailure(results));
      

      Following lines for isFailure():

      if (results == null || results.get(ModelService.RESPONSE_MESSAGE) == null) {
          return false;
      }
      return ModelService.RESPOND_FAIL.equals(results.get(ModelService.RESPONSE_MESSAGE));
      
      

      can be changed to

      return !(results == null || results.get(ModelService.RESPONSE_MESSAGE) == null) &&
              ModelService.RESPOND_FAIL.equals(results.get(ModelService.RESPONSE_MESSAGE));

      Following lines for isError():

       

      if (results == null || results.get(ModelService.RESPONSE_MESSAGE) == null) {
          return false;
      }
      return ModelService.RESPOND_ERROR.equals(results.get(ModelService.RESPONSE_MESSAGE));
      
      

      can be changed to

      return !(results == null || results.get(ModelService.RESPONSE_MESSAGE) == null) &&
              ModelService.RESPOND_ERROR.equals(results.get(ModelService.RESPONSE_MESSAGE));
      

       

        Attachments

        1. OFBIZ-10724.patch
          2 kB
          Aditya Sharma
        2. OFBIZ-10724.patch
          0.9 kB
          Aditya Sharma

          Activity

            People

            • Assignee:
              aditya.sharma Aditya Sharma
              Reporter:
              aditya.sharma Aditya Sharma
            • Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: