vendredi 30 mars 2018

how to minimize the nested if conditions in the below statement

  if (billAccounts.isEmpty()) {
      EvaluationResult.stopAnalysisWithResult(CreditCheckResultCode.TECHNICAL_FAULT_ERROR);
    } else {
      for (Long billAccountNumber : billAccounts) {
        if (noOverDueInvoice) {
          try {
            result = getOverdueInvoiceResponse(String.valueOf(billAccountNumber), requestHeader);
          } catch (Exception e) {
            result = "Operation aborted due to technical causes." + e.getMessage();
          }
          if (!result.equals(NO_DEBT)) {
            noOverDueInvoice = false;
          }
        } else {
          break;
        }
      }
      if (result.equals(NO_DEBT)) {
        creditCheckResponse.setResult(Long.valueOf(NO_DEBT_CODE));
      } else {
        creditCheckResponse.setResult(Long.valueOf(DEBT_CODE));
      }
      creditCheckResponse.setResultText(DEBT);
    }

Aucun commentaire:

Enregistrer un commentaire