public class RawSignature
extends java.lang.Object
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.
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
classname
The name of the declaring class of the method.
|
private java.lang.String |
name
The method name; for a constructor, same as the classname, except for inner classes where it
differs.
|
private @Nullable @DotSeparatedIdentifiers java.lang.String |
packageName
The package name of the class; null for the unnamed package.
|
private java.lang.Class<?>[] |
parameterTypes
The method parameter types.
|
Constructor and Description |
---|
RawSignature(@Nullable @DotSeparatedIdentifiers java.lang.String packageName,
java.lang.String classname,
java.lang.String name,
java.lang.Class<?>[] parameterTypes)
Create a
RawSignature object with the name and parameterTypes. |
Modifier and Type | Method and Description |
---|---|
private void |
checkRep()
Check the representation invariants of this.
|
static java.lang.String |
classNameToIdentifier(java.lang.String name)
Converts a class name to an identifier name.
|
static java.lang.String |
classToIdentifier(java.lang.Class<?> c)
Converts a class to an identifier name.
|
boolean |
equals(@Nullable java.lang.Object object) |
java.lang.String |
getClassname()
Return the class name for method in this signature.
|
java.lang.String |
getDeclarationArguments(java.util.List<java.lang.String> parameterNames)
Construct a parameter declaration string using the parameter names.
|
java.lang.String |
getName()
Return the method name for this signature.
|
@DotSeparatedIdentifiers java.lang.String |
getPackageName()
Return package name for method in this signature.
|
static @Nullable @DotSeparatedIdentifiers java.lang.String |
getPackageName(@Nullable java.lang.Package aPackage)
Returns the name of the given package, or null if it is the default package.
|
java.lang.Class<?>[] |
getParameterTypes()
Return the array of parameter types for this signature.
|
int |
hashCode() |
static RawSignature |
of(java.lang.reflect.Constructor<?> executable)
Create a
RawSignature object from the java.lang.reflect.Constructor . |
static RawSignature |
of(java.lang.reflect.Method executable)
Create a
RawSignature object from the java.lang.reflect.Method . |
java.lang.String |
toString() |
java.lang.String |
toStringDebug() |
private final @Nullable @DotSeparatedIdentifiers java.lang.String packageName
private final java.lang.String classname
private final java.lang.String name
private final java.lang.Class<?>[] parameterTypes
public RawSignature(@Nullable @DotSeparatedIdentifiers java.lang.String packageName, java.lang.String classname, java.lang.String name, java.lang.Class<?>[] parameterTypes)
RawSignature
object with the name and parameterTypes.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 anyprivate void checkRep(@UnknownInitialization RawSignature this)
public static RawSignature of(java.lang.reflect.Method executable)
RawSignature
object from the java.lang.reflect.Method
.executable
- the method from which to extract the signatureRawSignature
object for executable
public static RawSignature of(java.lang.reflect.Constructor<?> executable)
RawSignature
object from the java.lang.reflect.Constructor
.executable
- the constructor from which signature is extractedRawSignature
object for executable
public boolean equals(@Nullable java.lang.Object object)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
Returns the string representation of this signature in the format read by SignatureParser.parse(String, AccessibilityPredicate, ReflectionPredicate)
.
toString
in class java.lang.Object
public java.lang.String toStringDebug()
public @DotSeparatedIdentifiers java.lang.String getPackageName()
public java.lang.String getClassname()
public java.lang.String getName()
public java.lang.String getDeclarationArguments(java.util.List<java.lang.String> parameterNames)
parameterNames
- the parameter names to use to create declaration, length should be the
same as the number of parameter types in this signaturepublic java.lang.Class<?>[] getParameterTypes()
public static @Nullable @DotSeparatedIdentifiers java.lang.String getPackageName(@Nullable java.lang.Package aPackage)
Note: Java 9 uses the empty string whereas Java 8 uses null. This method uses null.
aPackage
- a packagepublic static java.lang.String classToIdentifier(java.lang.Class<?> c)
c
- a classpublic static java.lang.String classNameToIdentifier(java.lang.String name)
name
- a class name