|
|
@ -21,9 +21,12 @@ import java.lang.annotation.Annotation;
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
import java.lang.reflect.Modifier;
|
|
|
|
import java.lang.reflect.Modifier;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.function.BiConsumer;
|
|
|
|
import java.util.function.BiConsumer;
|
|
|
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
@ -126,13 +129,19 @@ class JavaBeanBinder implements DataObjectBinder {
|
|
|
|
|
|
|
|
|
|
|
|
private void addProperties(Class<?> type) {
|
|
|
|
private void addProperties(Class<?> type) {
|
|
|
|
while (type != null && !Object.class.equals(type)) {
|
|
|
|
while (type != null && !Object.class.equals(type)) {
|
|
|
|
Method[] declaredMethods = type.getDeclaredMethods();
|
|
|
|
Method[] declaredMethods = getSorted(type, Class::getDeclaredMethods, Method::getName);
|
|
|
|
Field[] declaredFields = type.getDeclaredFields();
|
|
|
|
Field[] declaredFields = getSorted(type, Class::getDeclaredFields, Field::getName);
|
|
|
|
addProperties(declaredMethods, declaredFields);
|
|
|
|
addProperties(declaredMethods, declaredFields);
|
|
|
|
type = type.getSuperclass();
|
|
|
|
type = type.getSuperclass();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private <S, E> E[] getSorted(S source, Function<S, E[]> elements, Function<E, String> name) {
|
|
|
|
|
|
|
|
E[] result = elements.apply(source);
|
|
|
|
|
|
|
|
Arrays.sort(result, Comparator.comparing(name));
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void addProperties(Method[] declaredMethods, Field[] declaredFields) {
|
|
|
|
protected void addProperties(Method[] declaredMethods, Field[] declaredFields) {
|
|
|
|
for (int i = 0; i < declaredMethods.length; i++) {
|
|
|
|
for (int i = 0; i < declaredMethods.length; i++) {
|
|
|
|
if (!isCandidate(declaredMethods[i])) {
|
|
|
|
if (!isCandidate(declaredMethods[i])) {
|
|
|
|