Package randoop.condition.specification
Class OperationSignature
java.lang.Object
randoop.condition.specification.OperationSignature
Represents the signature of a method or constructor for an
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.
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprivate
Gson serialization requires a default constructor.private
OperationSignature
(@ClassGetName String classname, String name, List<@ClassGetName String> parameterTypes) Create anOperationSignature
object given the names of the declaring class, method or constructor, and parameter types. -
Method Summary
Modifier and TypeMethodDescriptionboolean
static OperationSignature
forConstructorName
(@ClassGetName String classname, String simpleName, List<@ClassGetName String> parameterTypes) Create aOperationSignature
for the constructor of the class with the parameter types.static OperationSignature
forMethodName
(@ClassGetName String classname, String name, List<@ClassGetName String> parameterTypes) Create aOperationSignature
for the method in the named class, with the method name and parameter types.@ClassGetName String
Return the name of the declaring class of thisOperationSignature
.getName()
Return the name of thisOperationSignature
.Return the list of parameter type names for thisOperationSignature
.getTypeNames
(Class<?>[] classes) Creates a list of fully-qualified type names from the array ofClass<?>
objects.int
hashCode()
boolean
Indicates whether thisOperationSignature
represents a constructor.boolean
isValid()
Indicates whether thisOperationSignature
is a valid representation of a method or constructor.static OperationSignature
of
(AccessibleObject op) Returns an operation for a method or constructor given as ajava.lang.reflect.AccessibleObject
.static OperationSignature
of
(Constructor<?> constructor) Returns anOperationSignature
for a constructor given as ajava.lang.reflect.Constructor
.static OperationSignature
Returns anOperationSignature
for a method given as ajava.lang.reflect.Method
.toString()
-
Field Details
-
classname
The fully-qualified binary name of the declaring class of this operation. -
name
The name of this operation. For a method, is its simple name. For a constructor, is the fully-qualified name of the class. -
parameterTypes
The list of fully-qualified raw type names for the parameters of this operation.
-
-
Constructor Details
-
OperationSignature
private OperationSignature()Gson serialization requires a default constructor. -
OperationSignature
private OperationSignature(@ClassGetName String classname, String name, List<@ClassGetName String> parameterTypes) Create anOperationSignature
object given the names of the declaring class, method or constructor, and parameter types.- Parameters:
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 names
-
-
Method Details
-
forConstructorName
public static OperationSignature forConstructorName(@ClassGetName String classname, String simpleName, List<@ClassGetName String> parameterTypes) Create aOperationSignature
for the constructor of the class with the parameter types.- Parameters:
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 names- Returns:
- the
OperationSignature
for a constructor of the declaring class with the parameter types
-
forMethodName
public static OperationSignature forMethodName(@ClassGetName String classname, String name, List<@ClassGetName String> parameterTypes) Create aOperationSignature
for the method in the named class, with the method name and parameter types.- Parameters:
classname
- the name of the declaring classname
- the name of the methodparameterTypes
- the list of fully-qualified parameter type names- Returns:
- the
OperationSignature
for the named method in the declaring class, with the parameter types
-
of
Returns anOperationSignature
for a method given as ajava.lang.reflect.Method
.- Parameters:
method
- theMethod
for which operation is to be created- Returns:
- the
OperationSignature
with the class, name and parameter types ofmethod
-
of
Returns anOperationSignature
for a constructor given as ajava.lang.reflect.Constructor
.Note: the name and classname of a constructor are equal
- Parameters:
constructor
- theConstructor
for which an operation is to be created- Returns:
- the
OperationSignature
with the class and parameter types ofconstructor
-
of
Returns an operation for a method or constructor given as ajava.lang.reflect.AccessibleObject
.- Parameters:
op
- the method or constructor- Returns:
- an
OperationSignature
ifop
is a constructor or method, null if field
-
getClassname
Return the name of the declaring class of thisOperationSignature
.- Returns:
- the name of the declaring class of this operation
-
getName
Return the name of thisOperationSignature
.- Returns:
- the name of this operation
-
getParameterTypeNames
Return the list of parameter type names for thisOperationSignature
.- Returns:
- the list of parameter type names for this operation
-
isConstructor
public boolean isConstructor()Indicates whether thisOperationSignature
represents a constructor.- Returns:
true
if thisOperationSignature
represents a constructor,false
otherwise
-
isValid
public boolean isValid()Indicates whether thisOperationSignature
is a valid representation of a method or constructor.- Returns:
true
if the class and operation names are both non-null, non-empty and the type name list is non-null.
-
getTypeNames
Creates a list of fully-qualified type names from the array ofClass<?>
objects.- Parameters:
classes
- the array ofClass<?>
objects- Returns:
- the list of fully-qualified type names for the objects in
classes
-
equals
-
hashCode
public int hashCode() -
toString
-