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

Problems with equals method #46

Open
mpeters-tha opened this issue Oct 5, 2020 · 5 comments
Open

Problems with equals method #46

mpeters-tha opened this issue Oct 5, 2020 · 5 comments

Comments

@mpeters-tha
Copy link

Hello,

I have an issue, not really a bug but maybe an improvement.
Here is the use case:

  • I create a hash from a picture, then I store it on the disk as a String.
  • I retrieve this string and I create a new Hash object.
  • I run the equals method on hash from step 1 and 2, it returns false.

After investigation, I found it is because the following part in equals method:
if (getClass() != obj.getClass())
return false;
My Hash from step 1 is of class: com.github.kilianB.hashAlgorithms.DifferenceHash$DHash while the second one is of class: com.github.kilianB.hash.Hash.

I tried to cast the first one in (Hash) but it doesn't seems to view the object as it.

One way to solve this migh be to do something like this in equals method intead of using the .getClass():
if (!(obj instanceof Hash))
return false;

Cheers.
Matt

@KilianB
Copy link
Owner

KilianB commented Oct 5, 2020

Thanks for the comment. Would you be willing to create a small pull request? Then I can take a look at it and see if the change would break other places.

@mpeters-tha
Copy link
Author

Haha, I'm not devlopper, never done that, but I can try 👍

@mpeters-tha
Copy link
Author

Hi again, Sorry I need some help here. I've installed github desktop on my PC, cloned the repo, created a branch, edited the Hash.java file and commited the change, but when I want to publish my branch, it says "It looks like you don't have write access to kilianb / JImageHash". Did I miss something ? Should I create a fork instead, as proposed by gitHub ?

@KilianB
Copy link
Owner

KilianB commented Oct 6, 2020

Yes exactly, this is how git works . You create a fork (your own working copy of the code), which you are free to modify in any way you like.

You then can make changes

git add .
git commit -m "message"
git push

And afterwards create a pull request (this can be done via the github ui). Due to this process no one is able to change the code of a repository without permission of the actual owner but since your version is also online everyone can just download your version and try it out as well as be able to see who made the changes afterwards.

@mpeters-tha
Copy link
Author

Thanks. Done, Sorry for my newbeeness.

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