Skip to content

Commit a042714

Browse files
committed
Internal refactoring
1 parent 7caf777 commit a042714

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/main/java/org/apache/commons/beanutils2/PropertyUtilsBean.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ private BeanIntrospectionData fetchIntrospectionData(final Class<?> beanClass) {
295295
return new BeanIntrospectionData(ictx.getPropertyDescriptors());
296296
}
297297

298+
private Method getAccessibleMethod(final Object bean, Method writeMethod) {
299+
return MethodUtils.getAccessibleMethod(bean.getClass(), writeMethod);
300+
}
301+
298302
/**
299303
* Gets the value of the specified indexed property of the specified bean, with no type conversions. The zero-relative index of the required value must be
300304
* included (in square brackets) as a suffix to the property name, or {@code IllegalArgumentException} will be thrown. In addition to supporting the
@@ -374,7 +378,7 @@ public Object getIndexedProperty(final Object bean, final String name, final int
374378
// Call the indexed getter method if there is one
375379
if (descriptor instanceof IndexedPropertyDescriptor) {
376380
Method readMethod = ((IndexedPropertyDescriptor) descriptor).getIndexedReadMethod();
377-
readMethod = MethodUtils.getAccessibleMethod(bean.getClass(), readMethod);
381+
readMethod = getAccessibleMethod(bean, readMethod);
378382
if (readMethod != null) {
379383
try {
380384
return invokeMethod(readMethod, bean, Integer.valueOf(index));
@@ -497,7 +501,7 @@ public Object getMappedProperty(final Object bean, final String name, final Stri
497501
if (descriptor instanceof MappedPropertyDescriptor) {
498502
// Call the keyed getter method if there is one
499503
Method readMethod = ((MappedPropertyDescriptor) descriptor).getMappedReadMethod();
500-
readMethod = MethodUtils.getAccessibleMethod(bean.getClass(), readMethod);
504+
readMethod = getAccessibleMethod(bean, readMethod);
501505
if (readMethod == null) {
502506
throw new NoSuchMethodException("Property '" + name + "' has no mapped getter method on bean class '" + bean.getClass() + "'");
503507
}
@@ -1107,7 +1111,7 @@ public boolean isReadable(Object bean, String name) {
11071111
} else if (desc instanceof MappedPropertyDescriptor) {
11081112
readMethod = ((MappedPropertyDescriptor) desc).getMappedReadMethod();
11091113
}
1110-
readMethod = MethodUtils.getAccessibleMethod(bean.getClass(), readMethod);
1114+
readMethod = getAccessibleMethod(bean, readMethod);
11111115
}
11121116
return readMethod != null;
11131117
}
@@ -1170,7 +1174,7 @@ public boolean isWriteable(Object bean, String name) {
11701174
} else if (desc instanceof MappedPropertyDescriptor) {
11711175
writeMethod = ((MappedPropertyDescriptor) desc).getMappedWriteMethod();
11721176
}
1173-
writeMethod = MethodUtils.getAccessibleMethod(bean.getClass(), writeMethod);
1177+
writeMethod = getAccessibleMethod(bean, writeMethod);
11741178
}
11751179
return writeMethod != null;
11761180
}
@@ -1252,7 +1256,7 @@ public void setIndexedProperty(final Object bean, final String name, final int i
12521256
// Call the indexed setter method if there is one
12531257
if (descriptor instanceof IndexedPropertyDescriptor) {
12541258
Method writeMethod = ((IndexedPropertyDescriptor) descriptor).getIndexedWriteMethod();
1255-
writeMethod = MethodUtils.getAccessibleMethod(bean.getClass(), writeMethod);
1259+
writeMethod = getAccessibleMethod(bean, writeMethod);
12561260
if (writeMethod != null) {
12571261
try {
12581262
if (LOG.isTraceEnabled()) {
@@ -1397,7 +1401,7 @@ public void setMappedProperty(final Object bean, final String name, final String
13971401
if (descriptor instanceof MappedPropertyDescriptor) {
13981402
// Call the keyed setter method if there is one
13991403
Method mappedWriteMethod = ((MappedPropertyDescriptor) descriptor).getMappedWriteMethod();
1400-
mappedWriteMethod = MethodUtils.getAccessibleMethod(bean.getClass(), mappedWriteMethod);
1404+
mappedWriteMethod = getAccessibleMethod(bean, mappedWriteMethod);
14011405
if (mappedWriteMethod == null) {
14021406
throw new NoSuchMethodException("Property '" + name + "' has no mapped setter method on bean class '" + bean.getClass() + "'");
14031407
}

0 commit comments

Comments
 (0)