generated models do not have a hashcode that is consistent with equals
gotwarlost opened this issue · comments
Krishnan Anantheswaran commented
.. which means suffering if someone tried to stick these into sets and map keys.
$ cat x.rdl
type Foo struct {
String bar;
String baz;
}
$ rdl -ps generate java-model x.rdl
produces
//
// This file generated by rdl 1.4.13. Do not modify!
//
import com.yahoo.rdl.*;
//
// Foo -
//
public class Foo {
public String bar;
public String baz;
public Foo bar(String bar) {
this.bar = bar;
return this;
}
public Foo baz(String baz) {
this.baz = baz;
return this;
}
@Override
public boolean equals(Object another) {
if (this != another) {
if (another == null || another.getClass() != Foo.class) {
return false;
}
Foo a = (Foo) another;
if (bar == null ? a.bar != null : !bar.equals(a.bar)) {
return false;
}
if (baz == null ? a.baz != null : !baz.equals(a.baz)) {
return false;
}
}
return true;
}
}