Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Lombok's @EqualsAndHashCode(cacheStrategy = LAZY) #460

Closed
janeisklar opened this issue Jul 6, 2021 · 3 comments
Closed

Comments

@janeisklar
Copy link
Contributor

Is your feature request related to a problem? Please describe.
The following class currently can't be tested using equalsverifier:

@RequiredArgsConstructor
@EqualsAndHashCode(cacheStrategy = EqualsAndHashCode.CacheStrategy.LAZY)
public class CachedHashCode {
  private final String foo;
}

Equalsverifier fails with the following error message: hashCode relies on $hashCodeCache, but equals does not..

Describe the solution you'd like
I want to be able to test the hashcode method that is created by Lombok when using its lazy caching strategy.

Describe alternatives you've considered
Using .withCachedHashCode would seem like an obvious option to work around this, but this unfortunately only works with private methods and thus fails with Cached hashCode: Could not find calculateHashCodeMethod: must be 'private int hashCode()'.

Additional context
I will provide a pull request with an proposal on how to solve this in a bit.

@jqno
Copy link
Owner

jqno commented Jul 7, 2021

Thank you for the nice PR, and for even updating the docs! I'll let you know when I release this.

@jqno
Copy link
Owner

jqno commented Jul 9, 2021

I've just released version 3.7!

@jqno jqno closed this as completed Jul 9, 2021
@janeisklar
Copy link
Contributor Author

Thanks again for the extremely fast response time and a great utility:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants