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

generated models do not have a hashcode that is consistent with equals #11

Open
gotwarlost opened this issue May 15, 2017 · 0 comments
Open
Labels

Comments

@gotwarlost
Copy link

.. 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;
    }
}
@boynton boynton added the bug label Jul 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants