-
Notifications
You must be signed in to change notification settings - Fork 75
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
Suppress NULL_FIELDS check for a specific field #134
Comments
Thanks for opening a ticket for this. I'll add this in a future version. |
Hi, In addition to @effjay use case, we had to deal with a similar situation using the Spring Framework org.springframework.data.jpa.domain.AbstractPersistable class, which only has a single id field. The equals is implemented as follow:
which make sense for an entity to be persisted. When 2 entities are exaclty the same, but with null as id values, they can't be "equals". EqualsVerifier fails on this condition: Thanks a lot! |
Hi @sbraconnier, the |
Wow. My bad, I should have read the doc more carefully. I should also have thought that this wonderful library had this case cover :) It works like a charm! Many thanks! |
No problem. Glad it works! |
An additional requirement (from #164) is that it should also work when the constructor throws an exception if the specified field is null. |
worth mentioning that even though I've done.
the NPE is still thrown
|
@xenoterracide I can't reproduce this stacktrace. Can you please post some code? Especially the |
I've just released version 2.2, which adds this feature. |
Hi,
this may be an idea for a future version: Would be cool if I could suppress the NULL_FIELDS check for a specific field only.
We have a field in our class, which cannot be null (it is always initialized, private, and there is no setter) and so we don't do the null check.
The verifier manages to make it null by reflection and setAccessible(true), but that won't happen in real life.
I would love to suppress the NULL-check for this property only.
Thanks a lot and best regards
Daniel
The text was updated successfully, but these errors were encountered: