abstract class MemberUtils
extends java.lang.Object
Methods
/Constructors
,
extracted and refactored from MethodUtils
when it was imported from Commons BeanUtils.Modifier and Type | Class and Description |
---|---|
private static class |
MemberUtils.Executable
A class providing a subset of the API of java.lang.reflect.Executable in Java 1.8,
providing a common representation for function signatures for Constructors and Methods.
|
Modifier and Type | Field and Description |
---|---|
private static int |
ACCESS_TEST |
private static java.lang.Class<?>[] |
ORDERED_PRIMITIVE_TYPES
Array of primitive number types ordered by "promotability"
|
Constructor and Description |
---|
MemberUtils() |
Modifier and Type | Method and Description |
---|---|
(package private) static int |
compareConstructorFit(java.lang.reflect.Constructor<?> left,
java.lang.reflect.Constructor<?> right,
java.lang.Class<?>[] actual)
Compares the relative fitness of two Constructors in terms of how well they
match a set of runtime parameter types, such that a list ordered
by the results of the comparison would return the best match first
(least).
|
(package private) static int |
compareMethodFit(java.lang.reflect.Method left,
java.lang.reflect.Method right,
java.lang.Class<?>[] actual)
Compares the relative fitness of two Methods in terms of how well they
match a set of runtime parameter types, such that a list ordered
by the results of the comparison would return the best match first
(least).
|
private static int |
compareParameterTypes(MemberUtils.Executable left,
MemberUtils.Executable right,
java.lang.Class<?>[] actual)
Compares the relative fitness of two Executables in terms of how well they
match a set of runtime parameter types, such that a list ordered
by the results of the comparison would return the best match first
(least).
|
private static float |
getObjectTransformationCost(java.lang.Class<?> srcClass,
java.lang.Class<?> destClass)
Gets the number of steps required needed to turn the source class into
the destination class.
|
private static float |
getPrimitivePromotionCost(java.lang.Class<?> srcClass,
java.lang.Class<?> destClass)
Gets the number of steps required to promote a primitive number to another
type.
|
private static float |
getTotalTransformationCost(java.lang.Class<?>[] srcArgs,
MemberUtils.Executable executable)
Returns the sum of the object transformation cost for each class in the
source argument list.
|
(package private) static boolean |
isAccessible(java.lang.reflect.Member m)
Returns whether a
Member is accessible. |
(package private) static boolean |
isMatchingConstructor(java.lang.reflect.Constructor<?> method,
java.lang.Class<?>[] parameterTypes) |
private static boolean |
isMatchingExecutable(MemberUtils.Executable method,
java.lang.Class<?>[] parameterTypes) |
(package private) static boolean |
isMatchingMethod(java.lang.reflect.Method method,
java.lang.Class<?>[] parameterTypes) |
(package private) static boolean |
isPackageAccess(int modifiers)
Returns whether a given set of modifiers implies package access.
|
(package private) static boolean |
setAccessibleWorkaround(java.lang.reflect.AccessibleObject o)
XXX Default access superclass workaround.
|
private static final int ACCESS_TEST
private static final java.lang.Class<?>[] ORDERED_PRIMITIVE_TYPES
static boolean setAccessibleWorkaround(java.lang.reflect.AccessibleObject o)
public
class has a default access superclass with public
members,
these members are accessible. Calling them from compiled code works fine.
Unfortunately, on some JVMs, using reflection to invoke these members
seems to (wrongly) prevent access even when the modifier is public
.
Calling setAccessible(true)
solves the problem but will only work from
sufficiently privileged code. Better workarounds would be gratefully
accepted.o
- the AccessibleObject to set as accessiblestatic boolean isPackageAccess(int modifiers)
modifiers
- to testtrue
unless package
/protected
/private
modifier detectedstatic boolean isAccessible(java.lang.reflect.Member m)
Member
is accessible.m
- Member to checktrue
if m
is accessiblestatic int compareConstructorFit(java.lang.reflect.Constructor<?> left, java.lang.reflect.Constructor<?> right, java.lang.Class<?>[] actual)
left
- the "left" Constructorright
- the "right" Constructoractual
- the runtime parameter types to match against
left
/right
compare
semanticsstatic int compareMethodFit(java.lang.reflect.Method left, java.lang.reflect.Method right, java.lang.Class<?>[] actual)
left
- the "left" Methodright
- the "right" Methodactual
- the runtime parameter types to match against
left
/right
compare
semanticsprivate static int compareParameterTypes(MemberUtils.Executable left, MemberUtils.Executable right, java.lang.Class<?>[] actual)
left
- the "left" Executableright
- the "right" Executableactual
- the runtime parameter types to match against
left
/right
compare
semanticsprivate static float getTotalTransformationCost(java.lang.Class<?>[] srcArgs, MemberUtils.Executable executable)
srcArgs
- The source argumentsexecutable
- The executable to calculate transformation costs forprivate static float getObjectTransformationCost(java.lang.Class<?> srcClass, java.lang.Class<?> destClass)
srcClass
- The source classdestClass
- The destination classprivate static float getPrimitivePromotionCost(java.lang.Class<?> srcClass, java.lang.Class<?> destClass)
srcClass
- the (primitive) source classdestClass
- the (primitive) destination classstatic boolean isMatchingMethod(java.lang.reflect.Method method, java.lang.Class<?>[] parameterTypes)
static boolean isMatchingConstructor(java.lang.reflect.Constructor<?> method, java.lang.Class<?>[] parameterTypes)
private static boolean isMatchingExecutable(MemberUtils.Executable method, java.lang.Class<?>[] parameterTypes)