String.equals()
should be used when checking value equality on String literals. Using ==
or !=
compares object references, not the actual value of the Strings. This only modifies code where at least one side of the binary operation (==
or !=
) is a String literal, such as "someString" == someVariable;
. This is to prevent inadvertently changing code where referential equality is the user's intent.-Drewrite.activeRecipes=org.openrewrite.java.cleanup.StringLiteralEquality