Package randoop.reflection
Class RawSignature
java.lang.Object
randoop.reflection.RawSignature
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 Summary
Modifier and TypeFieldDescriptionprivate final String
The name of the declaring class of the method.private final String
The method name; for a constructor, same as the classname, except for inner classes where it differs.private final @DotSeparatedIdentifiers String
The package name of the class; null for the unnamed package.private final Class<?>[]
The method parameter types. -
Constructor Summary
ConstructorDescriptionRawSignature
(@DotSeparatedIdentifiers String packageName, String classname, String name, Class<?>[] parameterTypes) Create aRawSignature
object with the name and parameterTypes. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
classNameToIdentifier
(String name) Converts a class name to an identifier name.static String
classToIdentifier
(Class<?> c) Converts a class to an identifier name.boolean
Return the class name for method in this signature.getDeclarationArguments
(List<String> parameterNames) Construct a parameter declaration string using the parameter names.getName()
Return the method name for this signature.@DotSeparatedIdentifiers String
Return package name for method in this signature.static @Nullable @DotSeparatedIdentifiers String
getPackageName
(@Nullable Package aPackage) Returns the name of the given package, or null if it is the default package.Class<?>[]
Return the array of parameter types for this signature.int
hashCode()
static RawSignature
of
(Constructor<?> executable) Create aRawSignature
object from thejava.lang.reflect.Constructor
.static RawSignature
Create aRawSignature
object from thejava.lang.reflect.Method
.toString()
-
Field Details
-
packageName
The package name of the class; null for the unnamed package. -
classname
The name of the declaring class of the method. -
name
The method name; for a constructor, same as the classname, except for inner classes where it differs. -
parameterTypes
The method parameter types.
-
-
Constructor Details
-
RawSignature
public RawSignature(@DotSeparatedIdentifiers String packageName, String classname, String name, Class<?>[] parameterTypes) Create aRawSignature
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 classname
- the method name; for a constructor, same as the classnameparameterTypes
- the method parameter types, including the receiver type if any
-
-
Method Details
-
of
Create aRawSignature
object from thejava.lang.reflect.Method
.- Parameters:
executable
- the method from which to extract the signature- Returns:
- the
RawSignature
object forexecutable
-
of
Create aRawSignature
object from thejava.lang.reflect.Constructor
.- Parameters:
executable
- the constructor from which signature is extracted- Returns:
- the
RawSignature
object forexecutable
-
equals
-
hashCode
public int hashCode() -
toString
Returns the string representation of this signature in the format read by
SignatureParser.parse(String, AccessibilityPredicate, ReflectionPredicate)
. -
toStringDebug
-
getPackageName
Return package name for method in this signature.- Returns:
- the package name for this signature, null if default package
-
getClassname
Return the class name for method in this signature.- Returns:
- the class name for this signature
-
getName
Return the method name for this signature.- Returns:
- the method name for this signature
-
getDeclarationArguments
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
Return the array of parameter types for this signature.- Returns:
- the array of parameter types for this signature
-
getPackageName
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
Converts a class to an identifier name.- Parameters:
c
- a class- Returns:
- an identifier name produced from the class
-
classNameToIdentifier
Converts a class name to an identifier name.- Parameters:
name
- a class name- Returns:
- an identifier name produced from the class name
-