public class OperationSignature
extends java.lang.Object
OperationSpecification
so that
the java.lang.reflect.AccessibleObject
can be loaded, which is done by
SpecificationCollection.getAccessibleObject
.
The JSON serialization of this class is used to read the specifications for an operation given
using the --specifications
command-line option. The JSON should include a JSON object
labeled by the name of each field of this class, as in
{ "classname": "net.Connection", "name": "send", "parameterTypes": [ "int" ] }
The classname
must be the declaring class of the method. (For a constructor, the
classname
and operation name
will be identical.) If named class is not the
declaring class of the method, the method will not be found, and the enclosing specification will
not be used.
Modifier and Type | Field and Description |
---|---|
private @ClassGetName java.lang.String |
classname
The fully-qualified binary name of the declaring class of this operation.
|
private java.lang.String |
name
The name of this operation.
|
private java.util.List<java.lang.String> |
parameterTypes
The list of fully-qualified raw type names for the parameters of this operation.
|
Modifier | Constructor and Description |
---|---|
private |
OperationSignature()
Gson serialization requires a default constructor.
|
private |
OperationSignature(@ClassGetName java.lang.String classname,
java.lang.String name,
java.util.List<java.lang.String> parameterTypes)
Create an
OperationSignature object given the names of the declaring class, method or
constructor, and parameter types. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(@Nullable java.lang.Object object) |
static OperationSignature |
forConstructorName(@ClassGetName java.lang.String classname,
java.lang.String simpleName,
java.util.List<java.lang.String> parameterTypes)
Create a
OperationSignature for the constructor of the class with the parameter types. |
static OperationSignature |
forMethodName(@ClassGetName java.lang.String classname,
java.lang.String name,
java.util.List<java.lang.String> parameterTypes)
Create a
OperationSignature for the method in the named class, with the method name and
parameter types. |
@ClassGetName java.lang.String |
getClassname()
Return the name of the declaring class of this
OperationSignature . |
java.lang.String |
getName()
Return the name of this
OperationSignature . |
java.util.List<java.lang.String> |
getParameterTypeNames()
Return the list of parameter type names for this
OperationSignature . |
private static java.util.List<java.lang.String> |
getTypeNames(java.lang.Class<?>[] classes)
Creates a list of fully-qualified type names from the array of
Class<?> objects. |
int |
hashCode() |
boolean |
isConstructor()
Indicates whether this
OperationSignature represents a constructor. |
boolean |
isValid()
Indicates whether this
OperationSignature is a valid representation of a method or
constructor. |
static @Nullable OperationSignature |
of(java.lang.reflect.AccessibleObject op)
Returns an operation for a method or constructor given as a
java.lang.reflect.AccessibleObject . |
static OperationSignature |
of(java.lang.reflect.Constructor<?> constructor)
Returns an
OperationSignature for a constructor given as a java.lang.reflect.Constructor . |
static OperationSignature |
of(java.lang.reflect.Method method)
Returns an
OperationSignature for a method given as a java.lang.reflect.Method . |
java.lang.String |
toString() |
private final @ClassGetName java.lang.String classname
private final java.lang.String name
private final java.util.List<java.lang.String> parameterTypes
private OperationSignature()
private OperationSignature(@ClassGetName java.lang.String classname, java.lang.String name, java.util.List<java.lang.String> parameterTypes)
OperationSignature
object given the names of the declaring class, method or
constructor, and parameter types.classname
- the fully-qualified binary name of the declaring classname
- the name of the method or constructorparameterTypes
- the list of fully-qualified raw parameter type namespublic static OperationSignature forConstructorName(@ClassGetName java.lang.String classname, java.lang.String simpleName, java.util.List<java.lang.String> parameterTypes)
OperationSignature
for the constructor of the class with the parameter types.classname
- the fully-qualified raw name of the declaring classsimpleName
- the simple name of the class (and of the constructor)parameterTypes
- the list of fully-qualified parameter type namesOperationSignature
for a constructor of the declaring class with the
parameter typespublic static OperationSignature forMethodName(@ClassGetName java.lang.String classname, java.lang.String name, java.util.List<java.lang.String> parameterTypes)
OperationSignature
for the method in the named class, with the method name and
parameter types.classname
- the name of the declaring classname
- the name of the methodparameterTypes
- the list of fully-qualified parameter type namesOperationSignature
for the named method in the declaring class, with the
parameter typespublic static OperationSignature of(java.lang.reflect.Method method)
OperationSignature
for a method given as a java.lang.reflect.Method
.method
- the Method
for which operation is to be createdOperationSignature
with the class, name and parameter types of method
public static OperationSignature of(java.lang.reflect.Constructor<?> constructor)
OperationSignature
for a constructor given as a java.lang.reflect.Constructor
.
Note: the name and classname of a constructor are equal
constructor
- the Constructor
for which an operation is to be createdOperationSignature
with the class and parameter types of constructor
public static @Nullable OperationSignature of(java.lang.reflect.AccessibleObject op)
java.lang.reflect.AccessibleObject
.op
- the method or constructorOperationSignature
if op
is a constructor or method, null if fieldpublic @ClassGetName java.lang.String getClassname()
OperationSignature
.public java.lang.String getName()
OperationSignature
.public java.util.List<java.lang.String> getParameterTypeNames()
OperationSignature
.public boolean isConstructor()
OperationSignature
represents a constructor.true
if this OperationSignature
represents a constructor, false
otherwisepublic boolean isValid()
OperationSignature
is a valid representation of a method or
constructor.true
if the class and operation names are both non-null, non-empty and the type
name list is non-nullprivate static java.util.List<java.lang.String> getTypeNames(java.lang.Class<?>[] classes)
Class<?>
objects.classes
- the array of Class<?>
objectsclasses
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()
toString
in class java.lang.Object