Java
'equals()' called on enum value
Warning
New
Last modified: 03 December 2024 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);
}
After the quick-fix is applied:
boolean foo(MyEnum value) {
return value == MyEnum.FOO;
}
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
EqualsCalledOnEnumConstant
Inspection Details | |
---|---|
By default bundled with: | |
Can be installed with plugin: | Java, 243.23126 |
Thanks for your feedback!
Was this page helpful?