Comparing objects should be done via the .equals() method. Comparison based on the == or the != operator compares the objects itself. Use equals() to determine whether two objects are equal in their data. Caution: its quickfix might change behaviour.
Since 0.8.0
Enumerations and static final fields are ignored.
Since 0.8.2
Bad code: |
Good code: |
|
if (modifier.getKeyword() == keyword) |
if (modifier.getKeyword().equals(keyword)) |
|
This code check requires Eclipse to resolve bindings. Enabling this code check increases build time.
Warnings generated by this codecheck can be suppressed by adding the @SuppressWarnings("equals-comparison")
annotation.
Note: @SuppressWarnings("equals-comparison")
used to be @SuppressWarnings("equals")
in version 0.8.0 and 0.8.1.