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 & uses less memory.| Modifier and Type | Class and Description |
|---|---|
| public static class | MethodKey.AmbiguousException
Simple distinguishable exception, used when we run across ambiguous overloading. |
| private abstract static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final MethodKey. | CONSTRUCTORS
The parameter matching service for constructors. |
| private static final int | HASH
The hash code constants. |
| private final int | hashCode
The hash code. |
| private static final int | INCOMPARABLE
A method/ctor doesn't match a previously compared one. |
| private static final int | LESS_SPECIFIC
whether a method/ctor is less specific than a previously compared one. |
| private final String | method
The method name. |
| private static final MethodKey. | METHODS
The parameter matching service for methods. |
| private static final int | MORE_SPECIFIC
whether a method/ctor is more specific than a previously compared one. |
| private static final Class | NOARGS
A marker for empty parameter list. |
| private final Class | params
The parameters. |
| Access | Constructor and Description |
|---|---|
| public | |
| pack-priv | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public String | |
| public boolean | equals(Object
the reference object with which to compare. obj)Overrides java. |
| pack-priv String | |
| public Constructor | Returns: the most specific constructor.a list of constructors. methods)Gets the most specific constructor that is applicable to the parameters of this key. |
| public Method | Returns: the most specific method.a list of methods. methods)Gets the most specific method that is applicable to the parameters of this key. |
| pack-priv Class | |
| public int | |
| public static boolean | Returns: true if either formal type is assignable from actual type, or formal is a primitive type and actual is its corresponding object type or an object type of a primitive type that can be converted to the formal type.the formal parameter type to which the actual
parameter type should be convertible formal, Class<?> the actual parameter type. actual, boolean whether or not we're dealing with the last parameter
in the method declaration 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). |
| public static boolean | Returns: true if either formal type is assignable from actual type, or formal and actual are both primitive types and actual can be subject to widening conversion to formal.the formal parameter type to which the actual
parameter type should be convertible formal, Class<?> the actual parameter type. actual, boolean whether or not we're dealing with the last parameter
in the method declaration 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. |
| public String |
| CONSTRUCTORS | back to summary |
|---|---|
| private static final MethodKey. The parameter matching service for constructors. | |
| HASH | back to summary |
|---|---|
| private static final int HASH The hash code constants. | |
| hashCode | back to summary |
|---|---|
| private final int hashCode The hash code. | |
| INCOMPARABLE | back to summary |
|---|---|
| private static final int INCOMPARABLE A method/ctor doesn't match a previously compared one. | |
| LESS_SPECIFIC | back to summary |
|---|---|
| private static final int LESS_SPECIFIC whether a method/ctor is less specific than a previously compared one. | |
| method | back to summary |
|---|---|
| private final String method The method name. | |
| METHODS | back to summary |
|---|---|
| private static final MethodKey. The parameter matching service for methods. | |
| MORE_SPECIFIC | back to summary |
|---|---|
| private static final int MORE_SPECIFIC whether a method/ctor is more specific than a previously compared one. | |
| NOARGS | back to summary |
|---|---|
| private static final Class<?>[] NOARGS A marker for empty parameter list. | |
| params | back to summary |
|---|---|
| private final Class<?>[] params The parameters. | |
| MethodKey | back to summary |
|---|---|
| public MethodKey(String aMethod, Object[] args) Creates a key from a method name and a set of arguments. | |
| MethodKey | back to summary |
|---|---|
| pack-priv MethodKey(Method aMethod) Creates a key from a method.
| |
| MethodKey | back to summary |
|---|---|
| pack-priv MethodKey(String aMethod, Class<?>[] args) Creates a key from a method name and a set of parameters. | |
| debugString | back to summary |
|---|---|
| public String debugString() Outputs a human readable debug representation of this key.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| getMethod | back to summary |
|---|---|
| pack-priv String getMethod() Gets this key's method name.
| |
| getMostSpecificConstructor | back to summary |
|---|---|
| public Constructor Gets the most specific constructor that is applicable to the parameters of this key.
| |
| getMostSpecificMethod | back to summary |
|---|---|
| public Method getMostSpecificMethod(List<Method> methods) Gets the most specific method that is applicable to the parameters of this key.
| |
| getParameters | back to summary |
|---|---|
| pack-priv Class Gets this key's method parameter classes.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| isInvocationConvertible | back to summary |
|---|---|
| public 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). This behavior is because this method is used to determine applicable methods for an actual parameter list, and primitive types are represented by their object duals in reflective method calls.
| |
| isStrictInvocationConvertible | back to summary |
|---|---|
| public 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. This method is used to determine the more specific type when comparing signatures of methods.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| Modifier and Type | Field and Description |
|---|---|
| private static final long | serialVersionUID
Version Id for serializable.
|
| Access | Constructor and Description |
|---|---|
| public |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides java. Version Id for serializable. | |
| AmbiguousException | back to summary |
|---|---|
| public AmbiguousException() | |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private LinkedList | Returns: a list that contains only applicable methods (number of formal and actual arguments matches, and argument types are assignable to formal types through a method invocation conversion).list of all candidate methods methods, Class<?>[] the actual types of the arguments classes)Returns all methods that are applicable to actual argument types. |
| private T | Returns: the most specific method.a list of methods. methods, Class<?>[] list of argument types. classes)Gets the most specific method that is applicable to actual argument types. |
| protected abstract Class | Returns: the parametersa method or constructor app)Extract the parameter types from its applicable argument. |
| private boolean | Returns: true if method is applicable to argumentsmethod that will be called method, Class<?>[] arguments to method classes)Returns true if the supplied method is applicable to actual argument types. |
| private boolean | Returns: see isMethodInvocationConvertible.the formal parameter type to which the actual
parameter type should be convertible formal, Class<?> the actual parameter type. actual, boolean whether or not we're dealing with the last parameter
in the method declaration possibleVarArg)
|
| private boolean | Returns: see isStrictMethodInvocationConvertible.the formal parameter type to which the actual
parameter type should be convertible formal, Class<?> the actual parameter type. actual, boolean whether or not we're dealing with the last parameter
in the method declaration possibleVarArg)
|
| private int | Returns: MORE_SPECIFIC if c1 is more specific than c2, LESS_SPECIFIC if c1 is less specific than c2, INCOMPARABLE if they are incomparable.first signature to compare c1, Class<?>[] second signature to compare c2)Determines which method signature (represented by a class array) is more specific. |
| Parameters | back to summary |
|---|---|
| private Parameters() | |
| getApplicables | back to summary |
|---|---|
| private LinkedList Returns all methods that are applicable to actual argument types.
| |
| getMostSpecific | back to summary |
|---|---|
| private T getMostSpecific(List<T> methods, Class<?>[] classes) Gets the most specific method that is applicable to actual argument types.
| |
| getParameterTypes | back to summary |
|---|---|
| protected abstract Class Extract the parameter types from its applicable argument.
| |
| isApplicable | back to summary |
|---|---|
| private boolean isApplicable(T method, Class<?>[] classes) Returns true if the supplied method is applicable to actual argument types.
| |
| isConvertible | back to summary |
|---|---|
private boolean isConvertible(Class<?> formal, Class<?> actual, boolean possibleVarArg)
| |
| isStrictConvertible | back to summary |
|---|---|
private boolean isStrictConvertible(Class<?> formal, Class<?> actual, boolean possibleVarArg)
| |
| moreSpecific | back to summary |
|---|---|
| private int moreSpecific(Class<?>[] c1, Class<?>[] c2) Determines which method signature (represented by a class array) is more specific. This defines a partial ordering on the method signatures. | |