public class ClassMap
extends java.lang.Object
java.lang.Method objects by a concatenation of the method name and
the names of classes that make up the parameters.| Modifier and Type | Class and Description |
|---|---|
private static class |
ClassMap.CacheMiss
represents a miss on the cached data.
|
private static class |
ClassMap.MethodInfo
Used for the iterative discovery process for public methods.
|
| Modifier and Type | Field and Description |
|---|---|
private static ClassMap.CacheMiss |
CACHE_MISS
constant for a miss on the cached data.
|
private java.lang.Class |
clazz
Class passed into the constructor used to as the basis for the Method
map.
|
private java.util.Map |
methodCache
Cache of Methods, or CACHE_MISS, keyed by method name and actual
arguments used to find it.
|
private MethodMap |
methodMap
map from method name and args to a
Method. |
private static java.lang.Object |
OBJECT
represents null or missing arguments.
|
| Constructor and Description |
|---|
ClassMap(java.lang.Class aClass)
Standard constructor.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.reflect.Method |
findMethod(java.lang.String name,
java.lang.Object[] params)
Find a Method using the methodKey provided.
|
private static java.lang.reflect.Method[] |
getAccessibleMethods(java.lang.Class clazz)
Retrieves public methods for a class.
|
private static int |
getAccessibleMethods(java.lang.Class clazz,
ClassMap.MethodInfo[] methodInfos,
int upcastCount)
Recursively finds a match for each method, starting with the class, and
then searching the superclass and interfaces.
|
(package private) java.lang.Class |
getCachedClass() |
private static java.lang.reflect.Method |
getPublicMethod(java.lang.Class clazz,
java.lang.String name,
java.lang.Class[] paramTypes)
Looks up the method with specified name and signature in the first public
superclass or implemented interface of the class.
|
static java.lang.reflect.Method |
getPublicMethod(java.lang.reflect.Method method)
For a given method, retrieves its publicly accessible counterpart.
|
private java.lang.String |
makeMethodKey(java.lang.reflect.Method method)
Make a methodKey for the given method using the concatenation of the name
and the types of the method parameters.
|
private static java.lang.String |
makeMethodKey(java.lang.String method,
java.lang.Object[] params) |
private void |
populateMethodCache()
Populate the Map of direct hits.
|
private static final ClassMap.CacheMiss CACHE_MISS
private static final java.lang.Object OBJECT
private java.lang.Class clazz
private final java.util.Map methodCache
private final MethodMap methodMap
Method.public ClassMap(java.lang.Class aClass)
aClass - the class to deconstruct.java.lang.Class getCachedClass()
public java.lang.reflect.Method findMethod(java.lang.String name,
java.lang.Object[] params)
throws MethodMap.AmbiguousException
name - method nameparams - method parametersMethodMethodMap.AmbiguousException - if the method and parameters are ambiguous.private void populateMethodCache()
private java.lang.String makeMethodKey(java.lang.reflect.Method method)
private static java.lang.String makeMethodKey(java.lang.String method,
java.lang.Object[] params)
private static java.lang.reflect.Method[] getAccessibleMethods(java.lang.Class clazz)
private static int getAccessibleMethods(java.lang.Class clazz,
ClassMap.MethodInfo[] methodInfos,
int upcastCount)
clazz - Class to checkmethodInfos - array of methods we are searching to matchupcastCount - current number of methods we have matchedpublic static java.lang.reflect.Method getPublicMethod(java.lang.reflect.Method method)
method - a method whose publicly callable counterpart is requested.private static java.lang.reflect.Method getPublicMethod(java.lang.Class clazz,
java.lang.String name,
java.lang.Class[] paramTypes)
class - the class whose method is soughtname - the name of the methodparamTypes - the classes of method parameters