public static String emptyToNull(String str) {
        return (str == null || str.length() == 0 ? null : str);
    }
public static String emptyToNull ( String str ) { return ( str == null || str . length ( ) == 0 ? null : str ) ; }
Returns the given string if it is nonempty; {@code null} otherwise.

@param str the string to test and possibly return
@return {@code string} itself if it is nonempty; {@code null} if it is empty or null