@Nullable
    public static String trimToNull(@Nullable String string) {
        return Optional.ofNullable(string)
                .map(String::trim)
                .filter(StringUtils::isNotEmpty)
                .orElse(null);
    }
@ Nullable public static String trimToNull ( @ Nullable String string ) { return Optional . ofNullable ( string ) . map ( String :: trim ) . filter ( StringUtils :: isNotEmpty ) . orElse ( null ) ; }
Trims the supplied string. If the string is empty or null before or after
trimming, null is returned.

@param string the string to trim
@return the trimmed string or null