Invocation API 1.1.0.Final

org.jboss.invocation.proxy
Class MethodIdentifier

java.lang.Object
  extended by 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
static MethodIdentifier EQUALS
          The method identifier for Object.equals().
static MethodIdentifier FINALIZE
          The method identifier for Object.finalize().
static MethodIdentifier HASH_CODE
          The method identifier for Object.hashCode().
static MethodIdentifier TO_STRING
          The method identifier for Object.toString().
 
Method Summary
 boolean equals(MethodIdentifier other)
          Determine whether this object is equal to another.
 boolean equals(Object other)
          Determine whether this object is equal to another.
static MethodIdentifier getIdentifier(Class<?> returnType, String name, Class<?>... parameterTypes)
          Construct a new instance using class objects for the parameter types.
static MethodIdentifier getIdentifier(String returnType, String name, String... parameterTypes)
          Construct a new instance using string names for the return and parameter types.
static MethodIdentifier getIdentifierForMethod(Method method)
          Get an identifier for the given reflection method.
 String getName()
          Get the method name.
 String[] getParameterTypes()
          Get the parameter type names, as strings.
 Method getPublicMethod(Class<?> clazz)
          Look up a public method matching this method identifier using reflection.
 String getReturnType()
          Get the method return type name, as a string.
 int hashCode()
          Get the hash code for this method identifier.
 String toString()
          Get the human-readable representation of this identifier.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EQUALS

public static final MethodIdentifier EQUALS
The method identifier for Object.equals().


HASH_CODE

public static final MethodIdentifier HASH_CODE
The method identifier for Object.hashCode().


TO_STRING

public static final MethodIdentifier TO_STRING
The method identifier for Object.toString().


FINALIZE

public static final MethodIdentifier FINALIZE
The method identifier for Object.finalize().

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.

Overrides:
equals in class Object
Parameters:
other - the other object
Returns:
true if they are equal, false otherwise

equals

public boolean equals(MethodIdentifier other)
Determine whether this object is equal to another.

Parameters:
other - the other object
Returns:
true if they are equal, false otherwise

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 calling Arrays.hashCode(Object[]) on the parameter type name list (of strings).

Overrides:
hashCode in class Object
Returns:
the hash code

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 exists
ClassNotFoundException - if one of the classes referenced by this identifier are not found in clazz's class loader

toString

public String toString()
Get the human-readable representation of this identifier.

Overrides:
toString in class Object
Returns:
the string

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 type
name - the method name
parameterTypes - 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 name
name - the method name
parameterTypes - the method parameter type names
Returns:
the identifier

Invocation API 1.1.0.Final

Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.