Search code examples
javacoding-stylecheckstyle

Disable checkstyle for hashCode and equals


I need example configuration to totally disable check-style for hashCode() and equals() methods.


Solution

  • This is maybe not a direct answer to your question, but Lombok really shines on avoiding this sort of boilerplate code: http://projectlombok.org

    For this case, you can just annotate your classes with:

    @EqualsAndHashCode(of="id")
    

    or

    @EqualsAndHashCode(excludes={"these","fields","wont","be","compared"})
    

    Haven't tested it against checkstyle, though...