To write very robust and safe code, you should always treat the client as a potential attacker, a bad guy. Consider he will do his best to break your function with invalid arguments.Therefore the good practice is, always validate the input arguments, and throw NullPointerException or IllegalArgumentException accordingly.
Usually for sake of reuse and simplicity, there would be a utility class consisting of several static methods to do this. Then we call it like this
StringUtil.isNullOrEmpty(inputString);
However after read Google Guice’s code accidentally, I now realized this can be rewritten with utilization of import static
checkNotNullNorEmpty(cells);
As you need have the validation inserted at the beginning of every public method, the new approach is surely a time saver. Moreover, you can extend the utility class into a complete Preconditions class, and use it everywhere you want to ‘assert’ something.
Well this is just a very small tip about usage of import static, but life does get better, right? I bet you can also recall JUnit’s assertion way.