Polishing

This commit is contained in:
Sam Brannen
2022-07-15 15:28:47 +02:00
parent 77f8408e80
commit 1f3ea5133f
4 changed files with 10 additions and 11 deletions

View File

@@ -609,8 +609,8 @@ public abstract class BeanUtils {
* @return a corresponding MethodParameter object
*/
public static MethodParameter getWriteMethodParameter(PropertyDescriptor pd) {
if (pd instanceof GenericTypeAwarePropertyDescriptor) {
return new MethodParameter(((GenericTypeAwarePropertyDescriptor) pd).getWriteMethodParameter());
if (pd instanceof GenericTypeAwarePropertyDescriptor typeAwarePd) {
return new MethodParameter(typeAwarePd.getWriteMethodParameter());
}
else {
Method writeMethod = pd.getWriteMethod();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -267,9 +267,8 @@ public class BeanWrapperImpl extends AbstractNestablePropertyAccessor implements
@Override
public void setValue(@Nullable Object value) throws Exception {
Method writeMethod = (this.pd instanceof GenericTypeAwarePropertyDescriptor ?
((GenericTypeAwarePropertyDescriptor) this.pd).getWriteMethodForActualAccess() :
this.pd.getWriteMethod());
Method writeMethod = (this.pd instanceof GenericTypeAwarePropertyDescriptor typeAwarePd ?
typeAwarePd.getWriteMethodForActualAccess() : this.pd.getWriteMethod());
ReflectionUtils.makeAccessible(writeMethod);
writeMethod.invoke(getWrappedInstance(), value);
}