Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of Guava #650

Open
berezovskyi opened this issue Nov 11, 2024 · 1 comment · May be fixed by #669
Open

Get rid of Guava #650

berezovskyi opened this issue Nov 11, 2024 · 1 comment · May be fixed by #669

Comments

@berezovskyi
Copy link
Contributor

berezovskyi commented Nov 11, 2024

The less deps the better - less updating and CVE surface. We are only using string and immutable list utils.

For the lists, new JDKs have:

  • Collections.unmodifiableList(list);
  • List.of(...)

For strings, I have a small utils class:

class StringUtils {
    private static final Pattern CONTROL_CHAR_PATTERN = Pattern.compile("^\\p{Cc}&&[^\\r\\n\\t]+$");

    /**
     * Trim and strip control chars
     */
    public static String clean(String str) {
        if (str == null) return null;

        return CONTROL_CHAR_PATTERN.matcher(str).replaceAll("").trim();
    }

    /**
     * Trim and strip control chars; return an empty string if a null is encountered
     */
    public static String cleanNonNull(String str) {
        if (str == null) return "";

        return CONTROL_CHAR_PATTERN.matcher(str).replaceAll("").trim();
    }

    public static boolean isNullOrWhitespace(String str) {
        return str == null || str.isBlank();
    }


    public static boolean isNullOrEmpty(String str) {
        return str == null || str.isEmpty();
    }
}
@berezovskyi
Copy link
Contributor Author

and of commons-lang(3):

org.eclipse.lyo.server.ui.model.PreviewFactory uses StringUtils.isBlank

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant