Skip to content

Commit

Permalink
[bug]: #47 fixed PropertyDescriptor reference in Beans#getFieldValueA…
Browse files Browse the repository at this point in the history
…sString mthd
  • Loading branch information
millij committed Jul 22, 2024
1 parent 66fd0f6 commit d1be7a0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/java/io/github/millij/poi/util/Beans.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ private Beans() {
}


//
// Constants

private static final PropertyUtilsBean PROP_UTILS_BEAN = new PropertyUtilsBean();
private static final ConvertUtilsBean CONVERT_UTILS_BEAN = new ConvertUtilsBean();


// Static Utilities
// ------------------------------------------------------------------------

Expand Down Expand Up @@ -68,7 +75,7 @@ public static String getFieldName(final Method method) {
*/
public static String getFieldValueAsString(final Object beanObj, final String fieldName) throws Exception {
// Property Descriptor
final PropertyDescriptor pd = new PropertyDescriptor(fieldName, beanObj.getClass());
final PropertyDescriptor pd = PROP_UTILS_BEAN.getPropertyDescriptor(beanObj, fieldName);
final Method getterMtd = pd.getReadMethod();

final Object value = getterMtd.invoke(beanObj);
Expand Down Expand Up @@ -105,9 +112,6 @@ public static boolean isInstantiableType(final Class<?> clz) {
// Set Property
// ------------------------------------------------------------------------

private static final PropertyUtilsBean PROP_UTILS_BEAN = new PropertyUtilsBean();
private static final ConvertUtilsBean CONVERT_UTILS_BEAN = new ConvertUtilsBean();

public static void setProperty(final Object target, final String propName, final Object propValue,
final String format, final DateTimeType dateTimeType) throws Exception {
// Sanity checks
Expand Down

0 comments on commit d1be7a0

Please sign in to comment.