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

@Data needs noEqualsAndHashCode/equalsAndHashCode option #171

Closed
lombokissues opened this issue Jul 14, 2015 · 6 comments
Closed

@Data needs noEqualsAndHashCode/equalsAndHashCode option #171

lombokissues opened this issue Jul 14, 2015 · 6 comments

Comments

@lombokissues
Copy link

Migrated from Google Code (issue 98)

@lombokissues
Copy link
Author

👤 vit6ak   🕗 Jan 17, 2010 at 13:36 UTC

Maybe you think that following code is a solution:
@ Override
public boolean equals(Object obj) {
return super.equals(obj);
}

@ Override
public int hashCode() {
    return super.hashCode();
}

However, consider these two situations:

  • equals and hashCode are final
  • you are subclassing a class: you get a warning about these two methods.
    You can solve it vy @ EqualsAndHashCode(callSuper=false), but you get
    another warning.

So I think that @ Data(noEqualsAndHashCode=true) or
@ Data(equalsAndHashCode=false) it the best solution.

@lombokissues
Copy link
Author

👤 henri.tremblay   🕗 Mar 28, 2010 at 10:30 UTC

I support this idea. In fact I would also add a noToString. Something like:

public @ interface Data {
boolean addEqualsHashCode() default true;
boolean addGetters() default true;
boolean addSetters() default true;
boolean addToString() default true;
}

Another possibility is to allow Getter and Setter to target the class. Since ToString
and EqualsAndHashCode already exist, it will have the same result.

@lombokissues
Copy link
Author

👤 reinierz   🕗 Jul 19, 2010 at 15:03 UTC

@ Getter and @ Setter are now capable of targetting the class, as of v0.9.3 which we'll release next.

@lombokissues
Copy link
Author

👤 vit6ak   🕗 Jul 19, 2010 at 16:23 UTC

It is great. The only missing thing is IMHO extracted constructor generation which is discussed in Lombok Ggroups. I have to read the discussion in future.

@lombokissues
Copy link
Author

👤 r.spilker   🕗 Jul 20, 2010 at 07:50 UTC

It's there. See issue #152

@lombokissues
Copy link
Author

End of migration

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

1 participant