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

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • Trunk
    • None
    • framework
    • 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

            adityasharma Aditya Sharma
            adityasharma Aditya Sharma
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: