Author: lindner
Date: Mon Jan 12 02:15:11 2009
New Revision: 733666
URL: http://svn.apache.org/viewvc?rev=733666&view=rev
Log:
SHINDIG-793 | Patch from Yoichiro Tanaka | Invalid getter method is called when
getter method to have one or more args is exists
Modified:
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/BeanJsonConverter.java
Modified:
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/BeanJsonConverter.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/BeanJsonConverter.java?rev=733666&r1=733665&r2=733666&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/BeanJsonConverter.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/BeanJsonConverter.java
Mon Jan 12 02:15:11 2009
@@ -149,7 +149,7 @@
availableGetters = GETTER_METHODS.get(pojo.getClass());
if (availableGetters == null) {
- availableGetters = getMatchingMethods(pojo, GETTER_PREFIX);
+ availableGetters = getMatchingMethods(pojo, GETTER_PREFIX, false);
GETTER_METHODS.putIfAbsent(pojo.getClass(), availableGetters);
}
@@ -189,7 +189,7 @@
}
- private List<MethodPair> getMatchingMethods(Object pojo, String prefix) {
+ private List<MethodPair> getMatchingMethods(Object pojo, String prefix,
boolean allowHaveArgs) {
List<MethodPair> availableGetters = Lists.newArrayList();
Method[] methods = pojo.getClass().getMethods();
@@ -206,6 +206,11 @@
if (EXCLUDED_FIELDS.contains(fieldName.toLowerCase())) {
continue;
}
+ if (!allowHaveArgs) {
+ if (method.getParameterTypes().length != 0) {
+ continue;
+ }
+ }
availableGetters.add(new MethodPair(method, fieldName));
}
return availableGetters;
@@ -260,7 +265,7 @@
List<MethodPair> methods;
methods = SETTER_METHODS.get(pojo.getClass());
if (methods == null) {
- methods = getMatchingMethods(pojo, SETTER_PREFIX);
+ methods = getMatchingMethods(pojo, SETTER_PREFIX, true);
SETTER_METHODS.putIfAbsent(pojo.getClass(), methods);
}