Open Nicklas2751 opened 2 years ago
Not sure I want to generate equals()
& hasCode()
. Depends on the number of cases it needs to handle. If the array
is the only special case it looks manageable. :)
having Objects only
:
public boolean equals (Object o) {
if (this == o)
return true;
if (o == null || getClass () != o.getClass ())
return false;
Reference reference = (Reference) o;
return Objects.equals (ref, reference.ref)
&& Objects.equals (value, reference.value);
}
public int hashCode () {
return Objects.hash (ref, value);
}
having an array:
public boolean equals (Object o) {
if (this == o)
return true;
if (o == null || getClass () != o.getClass ())
return false;
Book book = (Book) o;
return Objects.equals (id, book.id)
&& Objects.equals (title, book.title)
&& Arrays.equals (authors, book.authors);
}
public int hashCode () {
int result = Objects.hash (id, title);
result = 31 * result + Arrays.hashCode (authors);
return result;
}
The generated model classes has neither a hash code nor an equals method. This leads to that when I wan't to test my endpoint implementations I always have to use a recursive comparison.
So it would be nice to be able to get the hashcode and equals method generated.