commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kris Nuttycombe" <>
Subject Re: [beanutils] PropertyUtils & DynaBeans
Date Fri, 10 Dec 2004 19:11:27 GMT
Niall Pemberton wrote:

>Maybe its not a bad idea, but then again there are easier methods - I uses
>caches which use the "name" of the DyanClass. Another issue is it would work
>for your "regular" DynaClass, but those that also implement the
>MutableDynaClass (e.g. LazyDynaClass) would have problems since dyna
>properties can be added/removed which would change the hash code.
This is a bit of a problem, but I suspect that in most cases where 
you're using a DynaClass as a hash key you probably
won't be mutating it. In any case, the general contract of hashCode only 
states that hash codes must remain constant so long
as no properties that are used in the equals() comparison are modified, 
so this shouldn't be unexpected behavior, and it is
in compliance with the general contract of equals().

>Also since DynaClass is just an interface we could change the
>implementations provided in BeanUtils but theres no way of guaranteeing that
>custom implementations outside of BeanUtils would implement it in this
>standard fashion.
I think that a two-pronged approach to this issue is probably the best: 
provide an abstract base class for DynaClass,
as I was suggesting, but have that delegate to a DynaUtils class as you 
suggest. This makes the functionality available
to anyone who's implementing DynaClass, but gives them the flexibility 
not to use it if it's not appropriate for their purposes.

>Perhaps the best way would be to provide a generateHashCode(DynaClass)
>method and compare DynaClasses method (and getDyanProperties() method)  in
>one of the utils beans to make it easier for people to implement these types
>of behaviours - maybe a new DynaUtils would be a good idea for this?
>If you think its worth it then submit a bugzilla ticket, preferably with
>code :-)
>P.S. toString() utility methods for DynaClass and DynaBean might make good
>additons as well.
I'll add builder methods for toString() to the DynaUtils class as well. 
One question, though: there doesn't appear to be any
public method to retrieve the keys of a mapped property or the number of 
items available from an indexed property.
I can go ahead and post my implementation to Bugzilla without supporting 
these property types, but it seems like these
might be important methods to add to DynaClass in some future release.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message