Skip to content

Recipe for replacing StringUtils#isBlank(CharSequence) and StringUtils#isNotBlank(CharSequence) #7

@DevDavido

Description

@DevDavido

What problem are you trying to solve?

Similar to the recipe which replaces the StringUtils#isEmpty(String) and StringUtils#isNotEmpty(String) [1], a recipe would be helpful which replaces StringUtils#isBlank(CharSequence) and StringUtils#isNotBlank(CharSequence) with its plain Java equivalent too.

What precondition(s) should be checked before applying this recipe?

At least Java 11 is required due to the availability of java.lang.String#isBlank().

Describe the situation before applying the recipe

class A {
    void foo(String bar) {
        boolean isBlankBar = StringUtils.isBlank(bar);
        boolean isNotBlankBar = StringUtils.isNotBlank(bar);
    }
}

Describe the situation after applying the recipe

class A {
    void foo(String bar) {
        boolean isBlankBar = (bar == null || bar.isBlank());
        boolean isNotBlankBar = (bar != null && !bar.isBlank());
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Recipes Wanted

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions