[
https://issues.apache.org/jira/browse/IMAGING-150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14263958#comment-14263958
]
Benedikt Ritter commented on IMAGING-150:
-----------------------------------------
Hello Stephan,
it looks like you have based your test against an outdated version of imaging
trunk. Can you update the patch for the lastest trunk? Otherwise I cannot apply
it.
Looking at your test, it's nice that you're using Hamcrest matchers. I like the
DSL style of testing. However you should better change:
{code:java}
assertThat(color1.hashCode() == color1copy.hashCode(), is(true));
{code}
to
{code:java}
assertThat(color1.hashCode(), equalTo(color1copy.hashCode))
{code}
and
{code:java}
assertThat(color1.equals(color1copy), is(true));
{code}
to
{code:java}
assertThat(color1, equalTo(color1copy));
{code}
Note that an identical hashCode for identical objects is no absolute
requirement of the hashCode contract. Only unequal objects must have different
hash codes.
Further more our checkstyle should warn you about if-blocks without curly
braces. Although it is more noisy, I'd like to see those curly braces in the
auto generated equals and hashCode methods.
Benedikt
> Implement equals and hashcode on color classes
> ----------------------------------------------
>
> Key: IMAGING-150
> URL: https://issues.apache.org/jira/browse/IMAGING-150
> Project: Commons Imaging
> Issue Type: Improvement
> Components: imaging.color.*
> Reporter: Benedikt Ritter
> Fix For: Patch Needed
>
> Attachments: IMAGING-150_001.patch
>
>
> All color objects in the color package should implement equals and hashcode.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)