public final class FunctionSignature extends Object implements LangElement, Cloneable
Modifier and Type | Class and Description |
---|---|
static class |
FunctionSignature.Builder
Builder class for
FunctionSignature . |
Modifier and Type | Method and Description |
---|---|
void |
appendArgumentTypeList(StringBuilder sb)
Appends argument type list with parenthesis.
|
void |
appendFreeTypeList(StringBuilder sb)
Appends a free type list e.g.
|
static FunctionSignature.Builder |
builder(String name)
Returns builder to build the function signature.
|
FunctionSignature |
clone() |
int |
getArgumentCount()
Returns the number of input parameters.
|
String |
getArgumentName(int i)
Returns i-th argument name.
|
String |
getArgumentNameList()
Returns a argument name list in parentheses e.g.
|
Type |
getArgumentType(int i)
Returns i-th type.
|
Type |
getArgumentType(String argName)
Returns the argument type for a given argument name.
|
String |
getArgumentTypeList()
Returns a argument type list in parentheses e.g.
|
String |
getArgumentTypeNameList()
Returns a argument type and name list in parentheses e.g.
|
Type |
getArgumentTypeVariadic(int i)
Returns i-th argument type considering also variadic arguments.
|
ClosureType |
getClosureType()
Returns the corresponding closure type.
|
ClosureType |
getClosureType(int argCount)
Returns the corresponding closure type.
|
FunctionConstraint |
getConstraint()
Returns the function constraint.
|
Object |
getData()
Returns the data.
|
String |
getDefinition()
Returns the textual definition of the signature.
|
int |
getFixedArgumentCount()
Returns the number of fixed input paramters.
|
Type |
getFreeTypeBound(FreeType freeType)
Returns the free type upper bound, or
null if there is no
bound defined. |
Map<FreeType,Type> |
getFreeTypeBounds() |
List<FreeType> |
getFreeTypes()
Returns the free types of this function.
|
List<Class<?>> |
getJavaArgumentTypes()
Returns list of argument types then compiled to java.
|
Map<String,String> |
getMetadata()
Returns the metadata of this function
|
String |
getMetadata(String key)
Returns the metadata value for a given key.
|
Set<Modifier> |
getModifiers()
Deprecated.
Use getter for each modifier
|
String |
getName()
Returns the name of this function.
|
NamespaceModel |
getNamespaceModel()
Returns the owner namespace model.
|
Operation |
getOperation()
Returns the operation that executes this method
|
QID |
getQID()
Returns
QID for this signature. |
Type |
getReturnType()
Returns the return type of this block.
|
SignatureParameter |
getSignatureParameter(int i)
Returns i-th signature parameter.
|
List<SignatureParameter> |
getSignatureParameters()
Returns signature parameters
|
String |
getSignatureString()
Returns string representing this signature.
|
Visibility |
getVisibility()
Returns the signature visibility.
|
boolean |
hasMetadata(String key)
Returns
true if this function has the metadata key. |
boolean |
isAbstract()
Returns
true if this method is abstract. |
boolean |
isClassMember()
Returns true if it is class member (method or constructor).
|
boolean |
isCompiled()
Returns true if function should be compiled to java.
|
boolean |
isConstructor()
Returns true if this is a constructor.
|
boolean |
isDeprecated()
Returns true if the function is deprecated.
|
boolean |
isExtensionMethod()
Returns true if the function is an extension method.
|
boolean |
isMethod()
Returns true if it is method.
|
boolean |
isPrivate()
Returns true if the function signature is private.
|
boolean |
isProtected()
Returns true if the function signature is protected.
|
boolean |
isPublic()
Returns true if the function signature is public.
|
boolean |
isSame(FunctionSignature signature)
Returns true if this signature is same as the other one.
|
boolean |
isSideEffect()
Returns true if the function has side effects.
|
boolean |
isStatic()
Returns whether the function is a static method of its namespace.
|
boolean |
isVariadic()
Returns true if the signature is variadic.
|
SignatureMapping |
match(int argCount,
Type type)
Returns mapping of the free types in this function signature such that the resulting closure
type is the most general type which is subtype of
type or null if such mapping does
not exist. |
SignatureMapping |
match(Type returnType,
Map<String,Type> args)
Returns mapping of the free types in this function signature to provided actual
named parameter types; or
null if such mapping is not possible. |
SignatureMapping |
match(Type returnType,
Type... actualTypes)
Returns mapping of the free types in this function signature to provided actual parameter
types; or null if such mapping is not possible.
|
void |
setData(Object data)
Sets the data.
|
void |
setNamespaceModel(NamespaceModel namespaceModel)
Sets the owner namespace model.
|
void |
setOperation(Operation operation)
Sets the operation that executes this method.
|
String |
toString() |
public Operation getOperation()
public void setOperation(Operation operation)
IllegalStateException
is thrown.operation
- IllegalStateException
- if the operation is already setpublic String getName()
getName
in interface LangElement
public List<FreeType> getFreeTypes()
public FunctionConstraint getConstraint()
public Map<String,String> getMetadata()
getMetadata
in interface LangElement
public String getMetadata(String key)
getMetadata
in interface LangElement
key
- public boolean hasMetadata(String key)
true
if this function has the metadata key.hasMetadata
in interface LangElement
key
- true
if this function has the metadata keypublic Type getFreeTypeBound(FreeType freeType)
null
if there is no
bound defined.freeType
- public Map<FreeType,Type> getFreeTypeBounds()
public String getSignatureString()
public void appendFreeTypeList(StringBuilder sb)
.
Free type bounds are not appended.
If the signature has no free types, nothing is appended.sb
- public String getArgumentTypeList()
(String, Integer)
public void appendArgumentTypeList(StringBuilder sb)
sb
- public String getArgumentNameList()
(arg0, arg1)
public String getArgumentTypeNameList()
(Object arg0, String arg1)
public boolean isStatic()
public Visibility getVisibility()
public boolean isPublic()
public boolean isPrivate()
public boolean isProtected()
public boolean isDeprecated()
public boolean isSideEffect()
public boolean isExtensionMethod()
@Deprecated public Set<Modifier> getModifiers()
public Object getData()
getData
in interface LangElement
public void setData(Object data)
data
- public NamespaceModel getNamespaceModel()
public void setNamespaceModel(NamespaceModel namespaceModel)
namespaceModel
- public static FunctionSignature.Builder builder(String name)
name
- function namepublic SignatureMapping match(Type returnType, Type... actualTypes)
returnType
- actualTypes
- actual types of parameters of the functionpublic SignatureMapping match(int argCount, Type type)
type
or null if such mapping does
not exist.argCount
- type
- NullPointerException
- if type
is null.public SignatureMapping match(Type returnType, Map<String,Type> args)
null
if such mapping is not possible.returnType
- args
- public boolean isSame(FunctionSignature signature)
signature
- signature to compare withtrue
iff this signature is equivalent to the other onepublic Type getArgumentTypeVariadic(int i)
i
- public int getArgumentCount()
public int getFixedArgumentCount()
public SignatureParameter getSignatureParameter(int i)
i
- IllegalArgumentException
- if i
is out of boundspublic Type getArgumentType(int i)
i
- IllegalArgumentException
- if i
is out of boundspublic String getArgumentName(int i)
i
- IllegalArgumentException
- if i
is out of boundspublic Type getReturnType()
public boolean isVariadic()
public ClosureType getClosureType(int argCount)
argCount
determines argument
count when the signature is variadic, if it is not, it must be the argument count.argCount
- IllegalArgumentException
- if argCount
is invalidpublic ClosureType getClosureType()
public List<SignatureParameter> getSignatureParameters()
public FunctionSignature clone()
public Type getArgumentType(String argName)
argName
- the argument namepublic boolean isMethod()
public boolean isConstructor()
public boolean isClassMember()
public boolean isAbstract()
true
if this method is abstract.true
if this method is abstractpublic boolean isCompiled()
public List<Class<?>> getJavaArgumentTypes()
public String getDefinition()
Copyright © 2007-2020 Whitestein Technologies. All Rights Reserved.