org.sonar.l10n.java.rules.squid.S1221.html Maven / Gradle / Ivy
The newest version!
Naming a method hashcode()
or equal
is either:
- A bug. Overriding
Object.hashCode()
or Object.equals
was meant and the application does not behave as expected.
- Done on purpose. The name however will confuse every other developer, who will think it is a bug.
In both cases, the method should be renamed.
Noncompliant Code Example
public int hashcode() { /* ... */ } // Noncompliant
public boolean equal(Object obj) { /* ... */ } // Noncompliant
Compliant Solution
@Override
public int hashCode() { /* ... */ }
public boolean equals(Object obj) { /* ... */ }
© 2015 - 2025 Weber Informatics LLC | Privacy Policy