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 :-)

Niall

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.


Kris


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to