Package org.jboss.invocation.proxy
Class MethodIdentifier
- java.lang.Object
-
- org.jboss.invocation.proxy.MethodIdentifier
-
- All Implemented Interfaces:
Serializable
public final class MethodIdentifier extends Object implements Serializable
A unique identification of a method within some class or interface which is class loader-agnostic. Suitable for serialization as well as usage as a hash table key.- Author:
- David M. Lloyd
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static MethodIdentifierCLONEThe method identifier forObject.clone().static MethodIdentifierEQUALSThe method identifier forObject.equals().static MethodIdentifierFINALIZEThe method identifier forObject.finalize().static MethodIdentifierHASH_CODEThe method identifier forObject.hashCode().static MethodIdentifierTO_STRINGThe method identifier forObject.toString().
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object other)Determine whether this object is equal to another.booleanequals(MethodIdentifier other)Determine whether this object is equal to another.static MethodIdentifiergetIdentifier(Class<?> returnType, String name, Class<?>... parameterTypes)Construct a new instance using class objects for the parameter types.static MethodIdentifiergetIdentifier(String returnType, String name, String... parameterTypes)Construct a new instance using string names for the return and parameter types.static MethodIdentifiergetIdentifierForMethod(Method method)Get an identifier for the given reflection method.StringgetName()Get the method name.String[]getParameterTypes()Get the parameter type names, as strings.MethodgetPublicMethod(Class<?> clazz)Look up a public method matching this method identifier using reflection.StringgetReturnType()Get the method return type name, as a string.inthashCode()Get the hash code for this method identifier.StringtoString()Get the human-readable representation of this identifier.
-
-
-
Field Detail
-
CLONE
public static final MethodIdentifier CLONE
The method identifier forObject.clone().
-
EQUALS
public static final MethodIdentifier EQUALS
The method identifier forObject.equals().
-
FINALIZE
public static final MethodIdentifier FINALIZE
The method identifier forObject.finalize().
-
HASH_CODE
public static final MethodIdentifier HASH_CODE
The method identifier forObject.hashCode().
-
TO_STRING
public static final MethodIdentifier TO_STRING
The method identifier forObject.toString().
-
-
Method Detail
-
getName
public String getName()
Get the method name.- Returns:
- the method name
-
getParameterTypes
public String[] getParameterTypes()
Get the parameter type names, as strings.- Returns:
- the parameter type names
-
getReturnType
public String getReturnType()
Get the method return type name, as a string.- Returns:
- the method return type name
-
equals
public boolean equals(Object other)
Determine whether this object is equal to another.
-
equals
public boolean equals(MethodIdentifier other)
Determine whether this object is equal to another.- Parameters:
other- the other object- Returns:
trueif they are equal,falseotherwise
-
hashCode
public int hashCode()
Get the hash code for this method identifier. The hash code is equal to:n * 7 + (r * 7 + a)where n is the method name's hash code, r is the method return type's name's hash code and a is the result of callingArrays.hashCode(Object[])on the parameter type name list (of strings).
-
getPublicMethod
public Method getPublicMethod(Class<?> clazz) throws NoSuchMethodException, ClassNotFoundException
Look up a public method matching this method identifier using reflection.- Parameters:
clazz- the class to search- Returns:
- the method
- Throws:
NoSuchMethodException- if no such method existsClassNotFoundException- if one of the classes referenced by this identifier are not found inclazz's class loader
-
toString
public String toString()
Get the human-readable representation of this identifier.
-
getIdentifierForMethod
public static MethodIdentifier getIdentifierForMethod(Method method)
Get an identifier for the given reflection method.- Parameters:
method- the method- Returns:
- the identifier
-
getIdentifier
public static MethodIdentifier getIdentifier(Class<?> returnType, String name, Class<?>... parameterTypes)
Construct a new instance using class objects for the parameter types.- Parameters:
returnType- the method return typename- the method nameparameterTypes- the method parameter types- Returns:
- the identifier
-
getIdentifier
public static MethodIdentifier getIdentifier(String returnType, String name, String... parameterTypes)
Construct a new instance using string names for the return and parameter types.- Parameters:
returnType- the return type namename- the method nameparameterTypes- the method parameter type names- Returns:
- the identifier
-
-