public class Parameter
extends AnnotatedNode
implements Variable
Represents a parameter in a method or constructor declaration.
Parameters support optional type information (defaults to java.lang.Object if not specified),
default values for optional parameters, and closure variable sharing.
Parameters implement the Variable interface to integrate with variable scope tracking.
| Modifiers | Name | Description |
|---|---|---|
static Parameter[] |
EMPTY_ARRAY |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public Expression |
getDefaultValue()Returns the default value expression for this parameter, or null if no default is specified. |
|
public Expression |
getInitialExpression()Returns the default value expression for this parameter, or null if no default is specified. |
|
public int |
getModifiers()Returns the modifiers (access flags) for this parameter as per org.objectweb.asm.Opcodes.
|
|
public String |
getName()Returns the parameter name. |
|
public ClassNode |
getOriginType()Returns the original type of this parameter before any wrapping of primitive types. |
|
public ClassNode |
getType()Returns the type of this parameter. |
|
public boolean |
hasInitialExpression()Returns true if this parameter has been assigned a default value expression. |
|
public boolean |
isClosureSharedVariable()Returns true if this parameter is a closure-shared variable, meaning it is captured and accessed by nested closures. |
|
public boolean |
isDynamicTyped()Returns true if this parameter has dynamic type information, meaning its type could not be determined at compile time. |
|
public boolean |
isImplicit()Returns true if this parameter is implicit in the source code, such as the receiver parameter in instance methods or parameters generated by the compiler. |
|
public boolean |
isInStaticContext()Returns true if this parameter is declared in a static context (static method or static initializer). |
|
public boolean |
isReceiver()Returns true if this parameter represents a receiver parameter (named "this") as specified by JSR 308. |
|
public void |
setClosureSharedVariable(boolean inClosure)Marks this parameter as being shared with nested closures, affecting how it is handled in bytecode generation and variable access patterns. |
|
public void |
setInStaticContext(boolean inStaticContext)Marks this parameter as being declared in a static context. |
|
public void |
setInitialExpression(Expression init)Sets the default value expression for this optional parameter. |
|
public void |
setModifiers(int modifiers)Sets the modifiers (access flags) for this parameter. |
|
public void |
setOriginType(ClassNode cn)Sets the original type of this parameter before primitive type wrapping. |
|
public void |
setType(ClassNode type)Sets the type of this parameter. |
|
public String |
toString() |
| Methods inherited from class | Name |
|---|---|
class AnnotatedNode |
addAnnotation, addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, getGroovydoc, getInstance, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSynthetic |
class ASTNode |
copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visit |
Creates a parameter with the specified type and name.
type - the ClassNode representing the parameter's typename - the parameter name (never null)Creates a parameter with a type, name, and default value expression. The parameter is marked as having a default value which makes it optional.
type - the ClassNode representing the parameter's typename - the parameter name (never null)defaultValue - an Expression providing the default value for this optional parameterReturns the default value expression for this parameter, or null if no default is specified.
Returns the default value expression for this parameter, or null if no default is specified. This is an alias for getDefaultValue().
Returns the modifiers (access flags) for this parameter as per org.objectweb.asm.Opcodes.
May include flags like ACC_FINAL or ACC_MANDATED.
Returns the parameter name.
Returns the original type of this parameter before any wrapping of primitive types. This preserves the distinction between primitive and boxed types.
Returns the type of this parameter. If the type has not been set, a dynamic type is returned.
Returns true if this parameter has been assigned a default value expression.
Returns true if this parameter is a closure-shared variable, meaning it is captured and accessed by nested closures.
Returns true if this parameter has dynamic type information, meaning its type could not be determined at compile time.
Returns true if this parameter is implicit in the source code, such as the receiver parameter
in instance methods or parameters generated by the compiler. This is determined by the
ACC_MANDATED modifier flag as per java.lang.reflect.Parameter#isImplicit().
Returns true if this parameter is declared in a static context (static method or static initializer).
Returns true if this parameter represents a receiver parameter (named "this") as specified by JSR 308. Receiver parameters allow annotations on instance method receivers.
Marks this parameter as being shared with nested closures, affecting how it is handled in bytecode generation and variable access patterns.
inClosure - true if this parameter is shared with closuresMarks this parameter as being declared in a static context.
inStaticContext - true if this parameter is in a static contextSets the default value expression for this optional parameter. If the expression is null, the parameter is marked as not having a default value.
init - the default value Expression, or null to remove a default valueSets the modifiers (access flags) for this parameter.
modifiers - the modifier flags from org.objectweb.asm.OpcodesSets the original type of this parameter before primitive type wrapping.
cn - the original ClassNodeSets the type of this parameter. If the type is dynamically typed, the parameter is marked as dynamically typed.
type - the ClassNode representing this parameter's typeCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.