You are viewing a plain text version of this content. The canonical link for it is here.
Posted to kato-spec@incubator.apache.org by Stuart Monteith <st...@stoo.me.uk> on 2009/07/23 10:22:20 UTC

JavaObject.getHashcode(), JavaObject.getPersistentHashCode()

Hi,
    I've just been reviewing the Java documentation for 
JavaObject.getHashcode(), JavaObject.getPersistentHashCode().
I am thinking they should be replaced by:

    JavaObject.getHashcode();
    JavaObject.isHashcodePersistent();

Where the first method will calculate a hashcode and return it if the 
object's hashcode is not persistent, and will returned the stored 
hashcode if it is persistent.
The second method returns true if the hashcode is persistent.
I'm thinking this avoids us doing:

    long hashcode;
    boolean persistent;
    try{
          hashcode = obj.getPersistentHashcode();
          persistent = true;
    }catch (DataUnavalable e) {
       hashcode = obj.getHashcode();
       persistent = false;
    }

we could instead do:

    long hashcode = obj.getHashcode();
    boolean persistent = obj.isHashcodePersistent();

the only reason that occurs to me to not do it this way is if it is in 
someway important to be able to get both hashcodes.

Thoughts?

    Stuart

-- 
Stuart Monteith
http://blog.stoo.me.uk/


Re: JavaObject.getHashcode(), JavaObject.getPersistentHashCode()

Posted by Steve Poole <sp...@googlemail.com>.
+1

On Thu, Jul 23, 2009 at 11:22 AM, Stuart Monteith <st...@stoo.me.uk>wrote:

> Hi,
>   I've just been reviewing the Java documentation for
> JavaObject.getHashcode(), JavaObject.getPersistentHashCode().
> I am thinking they should be replaced by:
>
>   JavaObject.getHashcode();
>   JavaObject.isHashcodePersistent();
>
> Where the first method will calculate a hashcode and return it if the
> object's hashcode is not persistent, and will returned the stored hashcode
> if it is persistent.
> The second method returns true if the hashcode is persistent.
> I'm thinking this avoids us doing:
>
>   long hashcode;
>   boolean persistent;
>   try{
>         hashcode = obj.getPersistentHashcode();
>         persistent = true;
>   }catch (DataUnavalable e) {
>      hashcode = obj.getHashcode();
>      persistent = false;
>   }
>
> we could instead do:
>
>   long hashcode = obj.getHashcode();
>   boolean persistent = obj.isHashcodePersistent();
>
> the only reason that occurs to me to not do it this way is if it is in
> someway important to be able to get both hashcodes.
>
> Thoughts?
>
>   Stuart
>
> --
> Stuart Monteith
> http://blog.stoo.me.uk/
>
>