Inspectopedia Help

'equals()' called on enum value

Reports equals() calls on enum constants.

Such calls can be replaced by an identity comparison (==) because two enum constants are equal only when they have the same identity.

A quick-fix is available to change the call to a comparison.

Example:

boolean foo(MyEnum value) { return value.equals(MyEnum.FOO); }
boolean foo(MyEnum value) { return value == MyEnum.FOO; }

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin:

Java, 241.14841

Last modified: 12 March 2024