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

LazilyParsedNumber does not implement eqals and hashCode methods #627

Closed
GoogleCodeExporter opened this issue Mar 19, 2015 · 2 comments
Closed
Assignees

Comments

@GoogleCodeExporter
Copy link

test case to reproduce the issue

package com.google.gson.internal;

import junit.framework.TestCase;

public class LazilyParsedNumberTest extends TestCase {

    public void testHashCode(){
        LazilyParsedNumber n1 = new LazilyParsedNumber("1");
        LazilyParsedNumber n1Another = new LazilyParsedNumber("1");
        assertEquals(n1.hashCode(), n1Another.hashCode());
    }

    public void testEquals(){
        LazilyParsedNumber n1 = new LazilyParsedNumber("1");
        LazilyParsedNumber n1Another = new LazilyParsedNumber("1");
        assertTrue(n1.equals(n1Another));
    }


What is the expected output? What do you see instead?
Any class should implement hashCode and equals when implementing Number 
interface.

What version of the product are you using? On what operating system?
2.3

Please provide any additional information below.
https://code.google.com/p/google-gson/issues/detail?id=523
Similar one.

I could work on these, but first I would like to know if there was any reason 
you decided not to implement these methods? 

Original issue reported on code.google.com by vrab...@gmail.com on 4 Feb 2015 at 12:06

@GoogleCodeExporter
Copy link
Author

This was an oversight. We should fix this. Thanks for the bug report and a 
nicely written test.

Original comment by inder123 on 12 Feb 2015 at 5:31

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

Thanks.
Do you have any plans with the 523?

I am not sure what the comment in the 523 bug report means.

Do you try implement equals to behave like in javascript?
1.0 == 1 

In this case implementing equals and hashCode to fulfill the java contract 
would need more work than just ask IDE to generate equals and hashCode methods.

Original comment by vrab...@gmail.com on 13 Feb 2015 at 8:18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants