Class RawSignature

java.lang.Object
randoop.reflection.RawSignature

public class RawSignature extends Object
Represents the raw type signature for an java.lang.reflect.AccessibleObject. This signature consists of the classname as a fully-qualified raw type, the method name, and the argument types as fully-qualified raw types. It does not include the method or constructor name.

The raw type signature for a constructor C() is C() instead of the reflection form C.<init>(). Also, the name and the classname of a constructor are the same.

  • Field Details

    • packageName

      private final @DotSeparatedIdentifiers String packageName
      The package name of the class; null for the unnamed package.
    • classname

      private final String classname
      The name of the declaring class of the method.
    • name

      private final String name
      The method name; for a constructor, same as the classname, except for inner classes where it differs.
    • parameterTypes

      private final Class<?>[] parameterTypes
      The method parameter types.
  • Constructor Details

    • RawSignature

      public RawSignature(@DotSeparatedIdentifiers String packageName, String classname, String name, Class<?>[] parameterTypes)
      Create a RawSignature object with the name and parameterTypes.
      Parameters:
      packageName - the package name of the class. The unnamed package is indicated by null.
      classname - the name of the class
      name - the method name; for a constructor, same as the classname
      parameterTypes - the method parameter types, including the receiver type if any
  • Method Details

    • of

      public static RawSignature of(Method executable)
      Create a RawSignature object from the java.lang.reflect.Method.
      Parameters:
      executable - the method from which to extract the signature
      Returns:
      the RawSignature object for executable
    • of

      public static RawSignature of(Constructor<?> executable)
      Create a RawSignature object from the java.lang.reflect.Constructor.
      Parameters:
      executable - the constructor from which signature is extracted
      Returns:
      the RawSignature object for executable
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()

      Returns the string representation of this signature in the format read by SignatureParser.parse(String, AccessibilityPredicate, ReflectionPredicate).

      Overrides:
      toString in class Object
    • toStringDebug

      public String toStringDebug()
    • getPackageName

      public @DotSeparatedIdentifiers String getPackageName()
      Return package name for method in this signature.
      Returns:
      the package name for this signature, null if default package
    • getClassname

      public String getClassname()
      Return the class name for method in this signature.
      Returns:
      the class name for this signature
    • getName

      public String getName()
      Return the method name for this signature.
      Returns:
      the method name for this signature
    • getDeclarationArguments

      public String getDeclarationArguments(List<String> parameterNames)
      Construct a parameter declaration string using the parameter names. This string contains type-parameter name pairs in the format needed for a method declaration and wrapped in parentheses.
      Parameters:
      parameterNames - the parameter names to use to create declaration, length should be the same as the number of parameter types in this signature
      Returns:
      the parameter declarations for this signature using the given parameter names
    • getParameterTypes

      public Class<?>[] getParameterTypes()
      Return the array of parameter types for this signature.
      Returns:
      the array of parameter types for this signature
    • getPackageName

      public static @Nullable @DotSeparatedIdentifiers String getPackageName(@Nullable Package aPackage)
      Returns the name of the given package, or null if it is the default package.

      Note: Java 9 uses the empty string whereas Java 8 uses null. This method uses null.

      Parameters:
      aPackage - a package
      Returns:
      the name of the given package, or null if it is the default package
    • classToIdentifier

      public static String classToIdentifier(Class<?> c)
      Converts a class to an identifier name.
      Parameters:
      c - a class
      Returns:
      an identifier name produced from the class
    • classNameToIdentifier

      public static String classNameToIdentifier(String name)
      Converts a class name to an identifier name.
      Parameters:
      name - a class name
      Returns:
      an identifier name produced from the class name