One step check for null value & emptiness of a string

前端 未结 7 1135
一向
一向 2020-12-18 23:51

I have a setter method.

Then when another (say generate) method is run, I need to check the value of my fields. So in the case of String property, I need to know if

7条回答
  •  星月不相逢
    2020-12-19 00:30

    Add maven dependency for com.google.guava

    Then in your code:

    import com.google.common.base.Strings;
    
    if(!Strings.isNullOrEmpty(s)) {
      // Do stuff here
    }
    

提交回复
热议问题