lundi 1 octobre 2018

Checking if statement , string not null

   String CompAspiration = String.valueOf(getBoolT3ValForElementTag(element, "comp-aspiration") ? Pris3BMdmMapper.getSurgeryCx("comp-aspiration") : null);
    LOG.debug("Testing ... ........ ..... .. compilication    " + CompAspiration);
    String CompChyleLeak = String.valueOf(getBoolT3ValForElementTag(element, "comp-chyle-leak") ? Pris3BMdmMapper.getSurgeryCx("comp-chyle-leak") : null);
    LOG.debug("Testing ... ........ ..... .. compilication    " + CompChyleLeak);
    String CompCsfLeak = String.valueOf(getBoolT3ValForElementTag(element, "comp-csf-leak") ? Pris3BMdmMapper.getSurgeryCx("comp-csf-leak") : null);
    LOG.debug("Testing ... ........ ..... .. compilication    " + CompCsfLeak);
    String CompSwallowDifficult = String.valueOf(getBoolT3ValForElementTag(element, "comp-swallow-difficult") ? Pris3BMdmMapper.getSurgeryCx("comp-swallow-difficult") : null);
    LOG.debug("Testing ... ........ ..... .. compilication    " + CompSwallowDifficult); 


  if( CompAspiration != null) {     
        sectionTreatment.getComplication().add(CompAspiration);
    }
    if(CompChyleLeak != null) {
        sectionTreatment.getComplication().add(CompChyleLeak);
    }
    if(CompCsfLeak != null) {
        sectionTreatment.getComplication().add(CompCsfLeak);
    }
    if(CompSwallowDifficult != null) {
        sectionTreatment.getComplication().add(CompSwallowDifficult);
    }

I have a code to checking not null using if statement. if String is not not null it will be add to ListArray, but condition still execute statement event condition is not true. I already use !CompAspiration.equals(null) but the result still same.

CAOromaxReader Testing ... ........ ..... .. compilication    null
CAOromaxReader Testing ... ........ .....compilication    02
CAOromaxReader Testing ... ........ ..... ..compilication    null
CAOromaxReader Testing ... ........ ..... ..compilication    04

Here is my output at console

"complication": ["null", "02", "null", "04"]

Here my output result , supposedly null should not be in the array. Thank you.

Aucun commentaire:

Enregistrer un commentaire