click-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bob Schellink <sab...@gmail.com>
Subject ensureObjectPathNotNull changes
Date Mon, 20 Oct 2008 17:12:02 GMT
Hi all,

I checked in some code which changes the way in which 
ensureObjectPathNotNull looks up getter methods.

Just making sure I am not missing something obvious with this change.

The previous code looped through all the methods and checked against 
the path if a getter method matches. Here is the code:

   String getterName = ClickUtils.toGetterName(value);
   Method foundMethod = null;
   Method[] methods = object.getClass().getMethods();
   for (int i = 0; i < methods.length; i++) {
     String name = methods[i].getName();
     if (name.equals(getterName)) {
       foundMethod = methods[i];
       break;
     }
     ...
   }

The new code looks up the getter using reflection:

Method method = null;
String getterName = ClickUtils.toGetterName(value);
Class sourceClass = object.getClass();
method = sourceClass.getMethod(getterName, null);

Was there a specific reason for the previous version? Perhaps 
performance issue?

If you see any problems with this change please give a shout so we can 
fix this before 1.5.

kind regards

bob


Mime
View raw message