incubator-graffito-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Connelly <dsconne...@adelphia.net>
Subject Re: ManageableCollectionUtil should not throw "unsupported" JcrMapping exception.
Date Mon, 04 Sep 2006 15:12:44 GMT
Christophe:

Please excuse me.   I really am creating too many red herrings, however 
interesting!    This problem is not at all as difficult as I am making it.

There is an extremely general fix for the "unsupported" problem in 
ManageableCollectionUtil.

As I should have considered, EList is a  java.util.Collection.   (And so 
it java.util.List.)  So its all very general.    The problem is that the 
*object* converter method in ManageableCollectionUtil applies a very 
restrictive test:  object.getClass().equals(Collection.class)

I think this can be generalized so it will almost never throw unsupported.

Why not add a general "catchall" test such as this, at the end of the 
other tests in the *object* getManageableCollection method:

            if (object instanceof Collection) {
                return new ManageableCollectionImpl((Collection)object);
            }

where ManageableCollectionImpl is a simple delegating wrapper for *any* 
Collection (or is a ManageableArrayList when the no-arg constructor is 
used)?

A similar fix for the *class* converter method is a bit trickier since 
all superinterfaces of the presented class need to be examined for the 
most specific fit (to avoid the delegation if possible).

       -- Dan

Mime
View raw message