Polishing

This commit is contained in:
Juergen Hoeller
2019-07-20 17:34:16 +02:00
parent c573eca3d8
commit 529125898a
6 changed files with 85 additions and 61 deletions

View File

@@ -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.
@@ -327,6 +327,7 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
}
/**
* Get the last read invoker pair.
* @deprecated as of 4.3.15 since it is not used within the framework anymore
*/
@Deprecated
@@ -384,10 +385,10 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
@Nullable
protected Method findGetterForProperty(String propertyName, Class<?> clazz, boolean mustBeStatic) {
Method method = findMethodForProperty(getPropertyMethodSuffixes(propertyName),
"get", clazz, mustBeStatic, 0, ANY_TYPES);
"get", clazz, mustBeStatic, 0, ANY_TYPES);
if (method == null) {
method = findMethodForProperty(getPropertyMethodSuffixes(propertyName),
"is", clazz, mustBeStatic, 0, BOOLEAN_TYPES);
"is", clazz, mustBeStatic, 0, BOOLEAN_TYPES);
}
return method;
}
@@ -419,6 +420,17 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
return null;
}
/**
* Return class methods ordered with non-bridge methods appearing higher.
*/
private Method[] getSortedMethods(Class<?> clazz) {
return this.sortedMethodsCache.computeIfAbsent(clazz, key -> {
Method[] methods = key.getMethods();
Arrays.sort(methods, (o1, o2) -> (o1.isBridge() == o2.isBridge() ? 0 : (o1.isBridge() ? 1 : -1)));
return methods;
});
}
/**
* Determine whether the given {@code Method} is a candidate for property access
* on an instance of the given target class.
@@ -432,17 +444,6 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
return true;
}
/**
* Return class methods ordered with non-bridge methods appearing higher.
*/
private Method[] getSortedMethods(Class<?> clazz) {
return this.sortedMethodsCache.computeIfAbsent(clazz, key -> {
Method[] methods = key.getMethods();
Arrays.sort(methods, (o1, o2) -> (o1.isBridge() == o2.isBridge() ? 0 : (o1.isBridge() ? 1 : -1)));
return methods;
});
}
/**
* Return the method suffixes for a given property name. The default implementation
* uses JavaBean conventions with additional support for properties of the form 'xY'