26
26
*/
27
27
public abstract class AbstractTag extends TemplateToken {
28
28
29
+ private ThreadLocal <Map <String , Method >> methodCache = new ThreadLocal <Map <String , Method >>();
29
30
private String argumentLine , body , tagName , matchingEnd = null ;
30
31
private int tagStartIndex = -1 , tagEndIndex = -1 , argumentsEndIndex = -1 ;
31
32
@@ -179,9 +180,6 @@ public boolean marchArgumentEnd(String template, int index) {
179
180
return false ;
180
181
}
181
182
182
-
183
- private ThreadLocal <Map <String , Method >> methodCache = new ThreadLocal <Map <String , Method >>();
184
-
185
183
/**
186
184
* Tries to get a property value from object.
187
185
*
@@ -202,18 +200,22 @@ protected final Object getValue(Object obj, String propertyName) throws Invocati
202
200
//try map
203
201
if (obj instanceof Map ) {
204
202
Map objectMap = (Map ) obj ;
205
- val = objectMap .get (propertyName );
203
+ return objectMap .get (propertyName );
206
204
}
207
205
208
206
if (val == null ) {
209
207
//try properties
210
208
val = executeMethod (obj , "get" + capitalize (propertyName ), null );
209
+ if (val != null )
210
+ return val ;
211
211
}
212
212
213
213
214
214
//try generic get method
215
215
if (val == null ) {
216
216
val = executeMethod (obj , "get" , propertyName );
217
+ if (val != null )
218
+ return val ;
217
219
}
218
220
219
221
@@ -223,6 +225,8 @@ protected final Object getValue(Object obj, String propertyName) throws Invocati
223
225
//TODO: optimize the same as methods.
224
226
Field f = obj .getClass ().getDeclaredField (propertyName );
225
227
val = f .get (obj );
228
+ if (val != null )
229
+ return val ;
226
230
227
231
} catch (NoSuchFieldException ignore ) {
228
232
} catch (IllegalAccessException ignore ) {
0 commit comments