-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
@EqualsAndHashCode/@ToString(onlyExplicitlyIncluded = true) - still takes all fields, when no fields are annotated with @...Include. #1772
Comments
I'd bet this has been fixed in 1.18, just can't see it in the changelog. |
I stopped upgrading from 1.16.20 because of this. |
@rspilker , please, test before closing this issue. Here's the PROOF that it DOESN'T WORK in 1.18.2.
|
The way the release process works is that features and fixes like these
land in Lombok Edge first. I don't think the commit fixing this has been
released yet.
See https://projectlombok.org/download-edge
…On Tue, Oct 23, 2018 at 9:29 AM Pavel Bekkerman ***@***.***> wrote:
@rspilker <https://github.com/rspilker> , please, test before closing
this issue.
Here's the PROOF that it DOESN'T WORK in 1.18.2.
===> testLombok_OnlyExplicitlyIncluded() - fails.
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import lombok.Data;
import lombok.EqualsAndHashCode;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class EqualsAndHashCodeTest2 {
static class Super {
private String field;
}
static class DummyVanilla extends Super {
private final String field;
public DummyVanilla(String field) {
super();
this.field = field;
}
@OverRide
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((field == null) ? 0 : field.hashCode());
return result;
}
@OverRide
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
DummyVanilla other = (DummyVanilla) obj;
if (field == null) {
if (other.field != null) {
return false;
}
} else if (!field.equals(other.field)) {
return false;
}
return true;
}
}
static class DummyVanilla_OnlyExplicitlyIncluded extends Super {
private final String field;
public DummyVanilla_OnlyExplicitlyIncluded(String field) {
super();
this.field = field;
}
}
@DaTa
@EqualsAndHashCode(callSuper = false)
static class DummyLombok extends Super {
private final String field;
}
@DaTa
@EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
static class DummyLombok_OnlyExplicitlyIncluded extends Super {
private final String field;
}
//////////////// Equals //////////////////////
@test
public void testVanilla() {
assertEquals(new DummyVanilla("test"), new DummyVanilla("test"));
}
@test
public void testLombok() {
assertEquals(new DummyLombok("test"), new DummyLombok("test"));
}
//////////////// NotEquals //////////////////////
@test
public void testObject() {
assertNotEquals(new Object(), new Object());
}
@test
public void testSuper() {
assertNotEquals(new Super(), new Super());
}
@test
public void testVanilla_OnlyExplicitlyIncluded() {
assertNotEquals(new DummyVanilla_OnlyExplicitlyIncluded("test"), new DummyVanilla_OnlyExplicitlyIncluded("test"));
}
@test
public void testLombok_OnlyExplicitlyIncluded() {
assertNotEquals(new DummyLombok_OnlyExplicitlyIncluded("test"), new DummyLombok_OnlyExplicitlyIncluded("test"));
}
}
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1772 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAKCRbYghTecmQOXsPWkAA1IF_-LC6C0ks5unsVcgaJpZM4VJVor>
.
--
"Don't only practice your art, but force your way into it's secrets, for it
and knowledge can raise men to the divine."
-- Ludwig von Beethoven
|
@randakar it's not on the Edge list either. |
I did add a test in the changeset I mentioned |
We might have forgotten to mention it in change logs. @wheredevel, did you test it against the latest edge release. Can you otherwise tell me what I did wrong in my test code? |
Doesn't work as expected. Instead, if nothing is annotated with @...Incude - all is included.
This is the workaround that worked for me:
Please, fix.
The text was updated successfully, but these errors were encountered: