|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.jexl3.internal.introspection.MethodKey
public final class MethodKey
A method key usable by the introspector cache.
This stores a method (or class) name and parameters.
This replaces the original key scheme which used to build the key by concatenating the method name and parameters class names as one string with the exception that primitive types were converted to their object class equivalents.
The key is still based on the same information, it is just wrapped in an object instead. Primitive type classes are converted to they object equivalent to make a key; int foo(int) and int foo(Integer) do generate the same key.
A key can be constructed either from arguments (array of objects) or from parameters (array of class). Roughly 3x faster than string key to access the map and uses less memory.
Nested Class Summary | |
---|---|
static class |
MethodKey.AmbiguousException
Simple distinguishable exception, used when we run across ambiguous overloading. |
Constructor Summary | |
---|---|
MethodKey(String aMethod,
Object[] args)
Creates a key from a method name and a set of arguments. |
Method Summary | |
---|---|
String |
debugString()
Outputs a human readable debug representation of this key. |
boolean |
equals(Object obj)
|
Constructor<?> |
getMostSpecificConstructor(Constructor<?>[] methods)
Gets the most specific constructor that is applicable to the parameters of this key. |
Method |
getMostSpecificMethod(Method[] methods)
Gets the most specific method that is applicable to the parameters of this key. |
int |
hashCode()
|
static boolean |
isInvocationConvertible(Class<?> formal,
Class<?> actual,
boolean possibleVarArg)
Determines whether a type represented by a class object is convertible to another type represented by a class object using a method invocation conversion, treating object types of primitive types as if they were primitive types (that is, a Boolean actual parameter type matches boolean primitive formal type). |
static boolean |
isStrictInvocationConvertible(Class<?> formal,
Class<?> actual,
boolean possibleVarArg)
Determines whether a type represented by a class object is convertible to another type represented by a class object using a method invocation conversion, without matching object and primitive types. |
static boolean |
isVarArgs(Method method)
Checks whether a method accepts a variable number of arguments. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MethodKey(String aMethod, Object[] args)
aMethod
- the method to generate the key fromargs
- the intended method argumentsMethod Detail |
---|
public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
public String toString()
toString
in class Object
public String debugString()
public static boolean isVarArgs(Method method)
May be due to a subtle bug in some JVMs, if a varargs method is an override, depending on (may be) the class introspection order, the isVarargs flag on the method itself will be false. To circumvent the potential problem, fetch the method with the same signature from the super-classes, - which will be different if override -and get the varargs flag from it.
method
- the method to check for varargs
public Method getMostSpecificMethod(Method[] methods)
methods
- a list of methods.
MethodKey.AmbiguousException
- if there is more than one.public Constructor<?> getMostSpecificConstructor(Constructor<?>[] methods)
methods
- a list of constructors.
MethodKey.AmbiguousException
- if there is more than one.public static boolean isInvocationConvertible(Class<?> formal, Class<?> actual, boolean possibleVarArg)
formal
- the formal parameter type to which the actual
parameter type should be convertibleactual
- the actual parameter type.possibleVarArg
- whether or not we're dealing with the last parameter
in the method declaration
public static boolean isStrictInvocationConvertible(Class<?> formal, Class<?> actual, boolean possibleVarArg)
formal
- the formal parameter type to which the actual
parameter type should be convertibleactual
- the actual parameter type.possibleVarArg
- whether or not we're dealing with the last parameter
in the method declaration
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |