Package com.globalmentor.java
Class MethodSignature
- java.lang.Object
-
- com.globalmentor.model.AbstractHashObject
-
- com.globalmentor.java.MethodSignature
-
public class MethodSignature extends AbstractHashObject
A lightweight encapsulation of a method's signature, without regard to its access restrictions or the class to which it belongs. The signature instance supportshashCode()
andequals(Object)
.- Author:
- Garret Wilson
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object object)
Determines if this object equals another object.static MethodSignature
forMethod(java.lang.reflect.Method method)
Creates and returns a method signature from the given method.static MethodSignature
forMethod(java.lang.reflect.Method method, boolean returnTypeSignificant)
Creates and returns a method signature from the given method.java.lang.String
getName()
java.util.List<java.lang.Class<?>>
getParameterTypes()
java.lang.Class<?>
getReturnType()
int
hashCode()
Returns the hash code of this object.boolean
isReturnTypeSignificant()
-
Methods inherited from class com.globalmentor.model.AbstractHashObject
toString
-
-
-
-
Method Detail
-
getName
public java.lang.String getName()
- Returns:
- The name of the method.
-
getReturnType
public java.lang.Class<?> getReturnType()
- Returns:
- The return type of the method.
-
getParameterTypes
public java.util.List<java.lang.Class<?>> getParameterTypes()
-
isReturnTypeSignificant
public boolean isReturnTypeSignificant()
- Returns:
- Whether, for purposes of equality, the return type is significant.
-
hashCode
public int hashCode()
Description copied from class:AbstractHashObject
Returns the hash code of this object. This version returns the hash code of the underlying objects.- Overrides:
hashCode
in classAbstractHashObject
- Returns:
- The hash code of this object.
-
equals
public boolean equals(java.lang.Object object)
Description copied from class:AbstractHashObject
Determines if this object equals another object. This version considers the given object equal to this object if it is of the same type as this object, and this object's decorated object'sObject.equals(Object)
method also returnstrue
for the objects's decorated object or both decorated objects arenull
.- Overrides:
equals
in classAbstractHashObject
- Parameters:
object
- The object to compare with this object.- Returns:
true
if the given object is considered equal to this object.
-
forMethod
public static MethodSignature forMethod(java.lang.reflect.Method method)
Creates and returns a method signature from the given method. The return type is considered significant for purposes of equality.- Parameters:
method
- The method for which a signature should be returned.- Returns:
- An object representing the signature of the given methods.
-
forMethod
public static MethodSignature forMethod(java.lang.reflect.Method method, boolean returnTypeSignificant)
Creates and returns a method signature from the given method.- Parameters:
method
- The method for which a signature should be returned.returnTypeSignificant
- Whether, for purposes of equality, the return type is significant.- Returns:
- An object representing the signature of the given methods.
-
-