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

Equals issue #52

Open
jmborer opened this issue May 25, 2016 · 3 comments
Open

Equals issue #52

jmborer opened this issue May 25, 2016 · 3 comments
Assignees
Labels

Comments

@jmborer
Copy link

jmborer commented May 25, 2016

Hello,

Long time ago, we used castor gen 1.3.1 and spotted an issue in the equals generation that we fixed and kept in our own version of castor-generator. Now we plan to upgrade to 1.4.1 and I checked if the issue is still there: yes it is.

In https://github.com/castor-data-binding/castor/blob/master/codegen/src/main/java/org/exolab/castor/builder/factory/SourceFactory.java

the block starting on line 1419:

 if (temp.getType().isPrimitive()) {
    jsc.add("if (this.");
    jsc.append(name);
    jsc.append(" != temp.");
    jsc.append(name);
    jsc.append(")");
  } else {

should be replaced by

               if (temp.getType().isPrimitive()) {
                    jsc.add("if (this.");
                    jsc.append(name);
                    jsc.append(" != temp.");
                    jsc.append(name);
                    jsc.append(")");
                    jsc.indent();
                    jsc.add("return false;");
                    jsc.unindent();
                } else {

And on line 1570 right after the

       if (state.getFieldInfoForChoice() != null
                && name.equals(state.getFieldInfoForChoice().getName())) {
            continue;
        }

block, it should be added

        if (name.startsWith("enumConstants")) {
            continue;
        }

Hope it helps

@wguttmn wguttmn self-assigned this May 25, 2016
@wguttmn wguttmn added the bug label May 25, 2016
@wguttmn
Copy link
Contributor

wguttmn commented May 25, 2016

Mind putting this into a pull request ? And adding a test case that allows you to replay the problem at hand would be of great benefit as well, so that it could be added to Castor's test suite.

@jmborer
Copy link
Author

jmborer commented May 26, 2016

We fixed this in 2011 on version 1.3.1. Unfortunately, I have forgotten how to reproduce the issue. Apparently equality of elements with enums seems to work properly now (1.4.1). If I find the solution, I will publish the test case.

@wguttmn
Copy link
Contributor

wguttmn commented Aug 17, 2016

Any more findings ?

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