`if (StringUtils.hasText(...) {` can replace this (and also check for all whitespace).