org.apache.hivemind.service
Class MethodSignature

java.lang.Object
  extended by org.apache.hivemind.service.MethodSignature

public class MethodSignature
extends java.lang.Object

A representation of a Method, identifying the name, return type, parameter types and exception types. Actual Method objects are tied to a particular class, and don't compare well with other otherwise identical Methods from other classes or interface; MethodSignatures are distinct from classes and compare well.

Because the intended purpose is to compare methods from interfaces (which are always public and abstract) we don't bother to actually track the modifiers. In addition, at this time, MethodSignature does not distinguish between instance and static methods.

Author:
Howard Lewis Ship

Constructor Summary
MethodSignature(java.lang.Class returnType, java.lang.String name, java.lang.Class[] parameterTypes, java.lang.Class[] exceptionTypes)
           
MethodSignature(java.lang.reflect.Method m)
           
 
Method Summary
 boolean equals(java.lang.Object o)
          Returns true if the other object is an instance of MethodSignature with identical values for return type, name, parameter types and exception types.
 java.lang.Class[] getExceptionTypes()
          Returns the exceptions for this method.
 java.lang.String getName()
           
 java.lang.Class[] getParameterTypes()
          Returns the parameter types for this method.
 java.lang.Class getReturnType()
           
 java.lang.String getUniqueId()
          Returns a string consisting of the name of the method and its parameter values.
 int hashCode()
           
 boolean isOverridingSignatureOf(MethodSignature ms)
          Returns true if this signature has the same return type, name and parameters types as the method signature passed in, and this signatures exceptions "trump" (are the same as, or super-implementations of, all exceptions thrown by the other method signature).
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MethodSignature

public MethodSignature(java.lang.Class returnType,
                       java.lang.String name,
                       java.lang.Class[] parameterTypes,
                       java.lang.Class[] exceptionTypes)

MethodSignature

public MethodSignature(java.lang.reflect.Method m)
Method Detail

getExceptionTypes

public java.lang.Class[] getExceptionTypes()
Returns the exceptions for this method. Caution: do not modify the returned array. May return null.


getName

public java.lang.String getName()

getParameterTypes

public java.lang.Class[] getParameterTypes()
Returns the parameter types for this method. May return null. Caution: do not modify the returned array.


getReturnType

public java.lang.Class getReturnType()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Returns true if the other object is an instance of MethodSignature with identical values for return type, name, parameter types and exception types.

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getUniqueId

public java.lang.String getUniqueId()
Returns a string consisting of the name of the method and its parameter values. This is similar to toString(), but omits the return type and information about thrown exceptions. A unique id is used by MethodIterator to identify overlapping methods (methods with the same name but different thrown exceptions).

Since:
1.1

isOverridingSignatureOf

public boolean isOverridingSignatureOf(MethodSignature ms)
Returns true if this signature has the same return type, name and parameters types as the method signature passed in, and this signatures exceptions "trump" (are the same as, or super-implementations of, all exceptions thrown by the other method signature).

Since:
1.1