|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2018 the original author or authors. |
|
|
|
|
* Copyright 2002-2019 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. |
|
|
|
|
@ -41,8 +41,8 @@ import org.springframework.util.ObjectUtils;
@@ -41,8 +41,8 @@ import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Decorator for a standard {@link BeanInfo} object, e.g. as created by |
|
|
|
|
* {@link Introspector#getBeanInfo(Class)}, designed to discover and register static |
|
|
|
|
* and/or non-void returning setter methods. For example: |
|
|
|
|
* {@link Introspector#getBeanInfo(Class)}, designed to discover and register |
|
|
|
|
* static and/or non-void returning setter methods. For example: |
|
|
|
|
* |
|
|
|
|
* <pre class="code"> |
|
|
|
|
* public class Bean { |
|
|
|
|
@ -145,11 +145,10 @@ class ExtendedBeanInfo implements BeanInfo {
@@ -145,11 +145,10 @@ class ExtendedBeanInfo implements BeanInfo {
|
|
|
|
|
|
|
|
|
|
public static boolean isCandidateWriteMethod(Method method) { |
|
|
|
|
String methodName = method.getName(); |
|
|
|
|
Class<?>[] parameterTypes = method.getParameterTypes(); |
|
|
|
|
int nParams = parameterTypes.length; |
|
|
|
|
int nParams = method.getParameterCount(); |
|
|
|
|
return (methodName.length() > 3 && methodName.startsWith("set") && Modifier.isPublic(method.getModifiers()) && |
|
|
|
|
(!void.class.isAssignableFrom(method.getReturnType()) || Modifier.isStatic(method.getModifiers())) && |
|
|
|
|
(nParams == 1 || (nParams == 2 && int.class == parameterTypes[0]))); |
|
|
|
|
(nParams == 1 || (nParams == 2 && int.class == method.getParameterTypes()[0]))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handleCandidateWriteMethod(Method method) throws IntrospectionException { |
|
|
|
|
@ -209,7 +208,7 @@ class ExtendedBeanInfo implements BeanInfo {
@@ -209,7 +208,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String propertyNameFor(Method method) { |
|
|
|
|
return Introspector.decapitalize(method.getName().substring(3, method.getName().length())); |
|
|
|
|
return Introspector.decapitalize(method.getName().substring(3)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -488,7 +487,7 @@ class ExtendedBeanInfo implements BeanInfo {
@@ -488,7 +487,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
* See java.beans.IndexedPropertyDescriptor#equals(java.lang.Object) |
|
|
|
|
* See java.beans.IndexedPropertyDescriptor#equals |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public boolean equals(Object other) { |
|
|
|
|
@ -535,11 +534,13 @@ class ExtendedBeanInfo implements BeanInfo {
@@ -535,11 +534,13 @@ class ExtendedBeanInfo implements BeanInfo {
|
|
|
|
|
public int compare(PropertyDescriptor desc1, PropertyDescriptor desc2) { |
|
|
|
|
String left = desc1.getName(); |
|
|
|
|
String right = desc2.getName(); |
|
|
|
|
byte[] leftBytes = left.getBytes(); |
|
|
|
|
byte[] rightBytes = right.getBytes(); |
|
|
|
|
for (int i = 0; i < left.length(); i++) { |
|
|
|
|
if (right.length() == i) { |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
int result = left.getBytes()[i] - right.getBytes()[i]; |
|
|
|
|
int result = leftBytes[i] - rightBytes[i]; |
|
|
|
|
if (result != 0) { |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|