Class 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 supports hashCode() and equals(Object).
    Author:
    Garret Wilson
    • 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 class AbstractHashObject
        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's Object.equals(Object) method also returns true for the objects's decorated object or both decorated objects are null.
        Overrides:
        equals in class AbstractHashObject
        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.