Ignore property when generating equal and hash codes

Let's say I have a Customer class:

public class Customer {

private String firstName;
private String lastName;
private String doNotAddMeToEquals;

//Getters and Setters below

}

I use the Guava Eclipse plugin in Eclipse to generate the equals () and hashCode () methods; however, I could also use eclipse -> Source -> Generate HashCode / Equals. In any case ... it doesn't matter.

Is there a way to annotate the doNotAddMeToEquals property in such a way that when I generate the equals and hashcode methods with the guava plugin that the property does not appear in the list?

Without changing the plugin or creating a template.

Thanks at Advance !!

+4
source share
1 answer

It looks like you want something like this:

http://projectlombok.org/features/EqualsAndHashCode.html

, equals hashcode.

+4

All Articles