[jira] Created: (LANG-411) HashCodeBuilder: expose typed hashing methods

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (LANG-411) HashCodeBuilder: expose typed hashing methods

ASF GitHub Bot (Jira)
HashCodeBuilder: expose typed hashing methods
---------------------------------------------

                 Key: LANG-411
                 URL: https://issues.apache.org/jira/browse/LANG-411
             Project: Commons Lang
          Issue Type: Wish
    Affects Versions: 2.3
            Reporter: Paul Benedict
            Priority: Minor
             Fix For: 2.4


HashCodeBuilder encapsulates the good advice of Joshua Bloch. He details how each java.lang type should be hashed. I want to use those too ... but without reflection. Please expose those as static methods:

hashInt, hashBoolean, etc.
They should take two parameters: the field value, and the hash multiplier value.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (LANG-411) HashCodeBuilder: expose typed hashing methods

ASF GitHub Bot (Jira)

     [ https://issues.apache.org/jira/browse/LANG-411?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell updated LANG-411:
-------------------------------

    Fix Version/s:     (was: 2.4)
                   3.0

Perhaps as a patch for ObjectUtils?

Making this 3.0 as there's no patch currently.

> HashCodeBuilder: expose typed hashing methods
> ---------------------------------------------
>
>                 Key: LANG-411
>                 URL: https://issues.apache.org/jira/browse/LANG-411
>             Project: Commons Lang
>          Issue Type: Wish
>    Affects Versions: 2.3
>            Reporter: Paul Benedict
>            Priority: Minor
>             Fix For: 3.0
>
>
> HashCodeBuilder encapsulates the good advice of Joshua Bloch. He details how each java.lang type should be hashed. I want to use those too ... but without reflection. Please expose those as static methods:
> hashInt, hashBoolean, etc.
> They should take two parameters: the field value, and the hash multiplier value.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (LANG-411) HashCodeBuilder: expose typed hashing methods

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

    [ https://issues.apache.org/jira/browse/LANG-411?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12631465#action_12631465 ]

Sebb commented on LANG-411:
---------------------------

The hashCode calculations are all available as overloaded methods on a HashCodeBuilder instance:

{code}
int hash = new HashCodeBuilder(17, 37).append(name)
{code}

If there really is a need to simplify this with a static method call for each different type, then a patch (with Javadoc and test cases) would be helpful.

> HashCodeBuilder: expose typed hashing methods
> ---------------------------------------------
>
>                 Key: LANG-411
>                 URL: https://issues.apache.org/jira/browse/LANG-411
>             Project: Commons Lang
>          Issue Type: Wish
>    Affects Versions: 2.3
>            Reporter: Paul Benedict
>            Priority: Minor
>             Fix For: 3.0
>
>
> HashCodeBuilder encapsulates the good advice of Joshua Bloch. He details how each java.lang type should be hashed. I want to use those too ... but without reflection. Please expose those as static methods:
> hashInt, hashBoolean, etc.
> They should take two parameters: the field value, and the hash multiplier value.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (LANG-411) HashCodeBuilder: expose typed hashing methods

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

    [ https://issues.apache.org/jira/browse/LANG-411?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12769545#action_12769545 ]

Henri Yandell commented on LANG-411:
------------------------------------

Must admit that if I were looking for it I would go to ObjectUtils.hashInt rather than HashCodeBuilder. Plus I wouldn't want the object creation. So +1 to the idea... hoping someone codes it before I have to. Paul? :)

> HashCodeBuilder: expose typed hashing methods
> ---------------------------------------------
>
>                 Key: LANG-411
>                 URL: https://issues.apache.org/jira/browse/LANG-411
>             Project: Commons Lang
>          Issue Type: Wish
>    Affects Versions: 2.3
>            Reporter: Paul Benedict
>            Priority: Minor
>             Fix For: 3.0
>
>
> HashCodeBuilder encapsulates the good advice of Joshua Bloch. He details how each java.lang type should be hashed. I want to use those too ... but without reflection. Please expose those as static methods:
> hashInt, hashBoolean, etc.
> They should take two parameters: the field value, and the hash multiplier value.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (LANG-411) HashCodeBuilder: expose typed hashing methods

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

    [ https://issues.apache.org/jira/browse/LANG-411?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12779324#action_12779324 ]

Paul Benedict commented on LANG-411:
------------------------------------

The default functionality of HashCodeBuilder will call static methods in ObjectUtils to create the hashes.

> HashCodeBuilder: expose typed hashing methods
> ---------------------------------------------
>
>                 Key: LANG-411
>                 URL: https://issues.apache.org/jira/browse/LANG-411
>             Project: Commons Lang
>          Issue Type: Wish
>    Affects Versions: 2.3
>            Reporter: Paul Benedict
>            Priority: Minor
>             Fix For: 3.0
>
>
> HashCodeBuilder encapsulates the good advice of Joshua Bloch. He details how each java.lang type should be hashed. I want to use those too ... but without reflection. Please expose those as static methods:
> hashInt, hashBoolean, etc.
> They should take two parameters: the field value, and the hash multiplier value.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (LANG-411) HashCodeBuilder: expose typed hashing methods

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

     [ https://issues.apache.org/jira/browse/LANG-411?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell updated LANG-411:
-------------------------------

    Fix Version/s:     (was: 3.0)
                   3.1

Moving to 3.1 as I don't see this as either a) a big enhancement or b) a backwards incompatible enhancement.

> HashCodeBuilder: expose typed hashing methods
> ---------------------------------------------
>
>                 Key: LANG-411
>                 URL: https://issues.apache.org/jira/browse/LANG-411
>             Project: Commons Lang
>          Issue Type: Wish
>          Components: lang.builder.*
>    Affects Versions: 2.3
>            Reporter: Paul Benedict
>            Priority: Minor
>             Fix For: 3.1
>
>
> HashCodeBuilder encapsulates the good advice of Joshua Bloch. He details how each java.lang type should be hashed. I want to use those too ... but without reflection. Please expose those as static methods:
> hashInt, hashBoolean, etc.
> They should take two parameters: the field value, and the hash multiplier value.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (LANG-411) HashCodeBuilder: expose typed hashing methods

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

     [ https://issues.apache.org/jira/browse/LANG-411?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sean Mickey updated LANG-411:
-----------------------------

    Attachment: ObjectUtils-Patch-Addresses-LANG-411-and-LANG-627.txt
                ObjectUtilsTest-Patch-Adds-Tests-For-Changes-To-Address-LANG-411-and-LANG-627.txt

I have created a patch to ObjectUtils that addresses LANG-411 and LANG-627. It is attached for review.

I have also created a corresponding patch to ObjectUtilsTest that unit tests the functionality added in the ObjectUtils patch. It is also attached for review.

I chose this simple set of changes because it lets me get my feet wet with something simple and straightforward, but that is also a fair amount of work so that it alleviates the load on some of the old hands.

I hope this is helpful and I look forward to all feedback. Thanks~

> HashCodeBuilder: expose typed hashing methods
> ---------------------------------------------
>
>                 Key: LANG-411
>                 URL: https://issues.apache.org/jira/browse/LANG-411
>             Project: Commons Lang
>          Issue Type: Wish
>          Components: lang.builder.*
>    Affects Versions: 2.3
>            Reporter: Paul Benedict
>            Priority: Minor
>             Fix For: 3.1
>
>         Attachments: ObjectUtils-Patch-Addresses-LANG-411-and-LANG-627.txt, ObjectUtilsTest-Patch-Adds-Tests-For-Changes-To-Address-LANG-411-and-LANG-627.txt
>
>
> HashCodeBuilder encapsulates the good advice of Joshua Bloch. He details how each java.lang type should be hashed. I want to use those too ... but without reflection. Please expose those as static methods:
> hashInt, hashBoolean, etc.
> They should take two parameters: the field value, and the hash multiplier value.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (LANG-411) HashCodeBuilder: expose typed hashing methods

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

    [ https://issues.apache.org/jira/browse/LANG-411?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12890375#action_12890375 ]

Henri Yandell commented on LANG-411:
------------------------------------

Thanks Sean.

I don't think ObjectUtils should have state, i.e. static setXyz methods aren't desirable.

It seems to me that the ObjectUtils API needs to be:

+    public static int hashBooleanArray(int currentHash, int multiplier, Boolean[] boolArray)

Putting the target on the end means we could consider using varargs in the API.

> HashCodeBuilder: expose typed hashing methods
> ---------------------------------------------
>
>                 Key: LANG-411
>                 URL: https://issues.apache.org/jira/browse/LANG-411
>             Project: Commons Lang
>          Issue Type: Wish
>          Components: lang.builder.*
>    Affects Versions: 2.3
>            Reporter: Paul Benedict
>            Priority: Minor
>             Fix For: 3.1
>
>         Attachments: ObjectUtils-Patch-Addresses-LANG-411-and-LANG-627.txt, ObjectUtilsTest-Patch-Adds-Tests-For-Changes-To-Address-LANG-411-and-LANG-627.txt
>
>
> HashCodeBuilder encapsulates the good advice of Joshua Bloch. He details how each java.lang type should be hashed. I want to use those too ... but without reflection. Please expose those as static methods:
> hashInt, hashBoolean, etc.
> They should take two parameters: the field value, and the hash multiplier value.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.