You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2014/01/03 20:36:31 UTC
svn commit: r1555228 - in
/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils:
BeanIntrospectionData.java PropertyUtilsBean.java
Author: oheger
Date: Fri Jan 3 19:36:31 2014
New Revision: 1555228
URL: http://svn.apache.org/r1555228
Log:
Added a method for obtaining a specific PropertyDescriptor to BeanIntrospectionData.
Modified:
commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanIntrospectionData.java
commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java
Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanIntrospectionData.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanIntrospectionData.java?rev=1555228&r1=1555227&r2=1555228&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanIntrospectionData.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanIntrospectionData.java Fri Jan 3 19:36:31 2014
@@ -60,4 +60,20 @@ class BeanIntrospectionData {
public PropertyDescriptor[] getDescriptors() {
return descriptors;
}
+
+ /**
+ * Returns the {@code PropertyDescriptor} for the property with the specified name. If
+ * this property is unknown, result is <b>null</b>.
+ *
+ * @param name the name of the property in question
+ * @return the {@code PropertyDescriptor} for this property or <b>null</b>
+ */
+ public PropertyDescriptor getDescriptor(String name) {
+ for (PropertyDescriptor pd : getDescriptors()) {
+ if (name.equals(pd.getName())) {
+ return pd;
+ }
+ }
+ return null;
+ }
}
Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java?rev=1555228&r1=1555227&r2=1555228&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java Fri Jan 3 19:36:31 2014
@@ -947,17 +947,12 @@ public class PropertyUtilsBean {
return (null);
}
- PropertyDescriptor[] descriptors = getPropertyDescriptors(bean);
- if (descriptors != null) {
-
- for (int i = 0; i < descriptors.length; i++) {
- if (name.equals(descriptors[i].getName())) {
- return (descriptors[i]);
- }
- }
+ BeanIntrospectionData data = getIntrospectionData(bean.getClass());
+ PropertyDescriptor result = data.getDescriptor(name);
+ if (result != null) {
+ return result;
}
- PropertyDescriptor result = null;
FastHashMap mappedDescriptors =
getMappedPropertyDescriptors(bean);
if (mappedDescriptors == null) {