Looking at CacheMarshaller200.marshallObject, we seem to have quite a big if chain. For
BETA2, I was thinking that we could create a static Map<Class, int> containing class
names and magic numbers, similar to the work we did for MethodDeclarations.
public static final Map COLLECTIONS = new HashMap();
static
{
COLLECTIONS.put(ArrayList.class, MAGICNUMBER_ARRAY_LIST);
}
...
int i = COLLECTIONS.get(o.getClass());
switch(i)
{
Case MAGICNUMBER_ARRAY_LIST: ...
}
Also, the instanceof if statements could be translated into this, specially bearing in
mind that when we unmarshall, we create new instances of the class we compared for in the
instanceof statement, so we would be back to the problem we had with the customer
collections.
Galder ZamarreƱo
Sr. Software Maintenance Engineer
JBoss, a division of Red Hat