Class CtParameterImpl<T>
java.lang.Object
spoon.support.reflect.declaration.CtElementImpl
spoon.support.reflect.declaration.CtNamedElementImpl
spoon.support.reflect.declaration.CtParameterImpl<T>
- All Implemented Interfaces:
Serializable
,Cloneable
,FactoryAccessor
,SourcePositionHolder
,CtElement
,CtModifiable
,CtNamedElement
,CtParameter<T>
,CtShadowable
,CtTypedElement<T>
,CtVariable<T>
,CtQueryable
,CtVisitable
The implementation for
CtParameter
.- Author:
- Renaud Pawlak
- See Also:
- Serialized Form
-
Field Summary
Fields inherited from class spoon.support.reflect.declaration.CtElementImpl
ERROR_MESSAGE_TO_STRING, factory, LOGGER, parent
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Accepts a visitor<C extends CtModifiable>
CaddModifier(ModifierKind modifier)
add a modifierclone()
Clone the element which calls this method in a new object.Gets the initialization expression assigned to the variable (also known as the initializer), when declared.Returns the modifiers of this element, excluding annotations.CtExecutable<?>
Gets the parent of current reference.Returns the corresponding reference.getType()
Gets this element's type.Gets the visibility of this modifiable element.boolean
hasModifier(ModifierKind modifier)
Tells if this element contains the given modifier.boolean
Returns true if it contains an abstract modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
isFinal()
Returns true if it contains a final modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
Returns true if this parameter is a lambda parameter with type defined using the `var` keyword (since Java 11).boolean
isNative()
Returns true if it contains a native modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
Returns true it the variable (field, localvariable) is jointly declared with a share type Eg int a,b; Warning: is computed on demandboolean
Returns true if it contains a private modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
Returns true if it contains a protected modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
isPublic()
Returns true if it contains a public modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
isShadow()
When an element isn't present in the factory (created in another factory), this element is considered as "shadow".boolean
isStatic()
Returns true if it contains a static modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
Returns true if it contains a strictfp modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
Returns true if it contains a synchronized modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
Returns true if it contains a transient modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
Returns true if this parameter accepts a variable number of arguments (must be the last parameter ofCtExecutable.getParameters()
).boolean
Returns true if it contains a volatile modifier (seeCtModifiable.hasModifier(ModifierKind)
)<C extends CtModifiable>
CremoveModifier(ModifierKind modifier)
remove a modifier<C extends CtVariable<T>>
CsetDefaultExpression(CtExpression<T> defaultExpression)
Sets the initialization expression assigned to the variable, when declared.<T extends CtModifiable>
TsetExtendedModifiers(Set<CtExtendedModifier> extendedModifiers)
<U extends CtParameter<T>>
UsetInferred(boolean inferred)
Set to true if this parameter is a lambda parameter with type defined using the `var` keyword.<C extends CtModifiable>
CsetModifiers(Set<ModifierKind> modifiers)
Sets the modifiers.<E extends CtShadowable>
EsetShadow(boolean isShadow)
Marks an element as shadow.<C extends CtTypedElement>
CsetType(CtTypeReference type)
Sets this element's type.<C extends CtParameter<T>>
CsetVarArgs(boolean varArgs)
Sets this parameter to have varargs.<C extends CtModifiable>
CsetVisibility(ModifierKind visibility)
Sets the visibility of this modifiable element (replaces old visibility).Methods inherited from class spoon.support.reflect.declaration.CtNamedElementImpl
getSimpleName, setSimpleName
Methods inherited from class spoon.support.reflect.declaration.CtElementImpl
addAnnotation, addComment, asIterable, comment, delete, descendantIterator, emptyList, emptySet, equals, filterChildren, getAllMetadata, getAnnotatedChildren, getAnnotation, getAnnotation, getAnnotations, getComments, getDirectChildren, getDocComment, getElements, getFactory, getMetadata, getMetadataKeys, getOriginalSourceFragment, getParent, getParent, getPath, getPosition, getReferencedTypes, getRoleInParent, getShortRepresentation, getValueByRole, hasAnnotation, hashCode, hasParent, isImplicit, isParentInitialized, map, map, prettyprint, putMetadata, removeAnnotation, removeComment, replace, replace, setAllMetadata, setAnnotations, setComments, setDocComment, setFactory, setImplicit, setParent, setPosition, setPositions, setValueByRole, toString, toStringDebug, unmodifiableList, updateAllParentsBelow
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface spoon.reflect.declaration.CtElement
addAnnotation, addComment, asIterable, delete, descendantIterator, getAllMetadata, getAnnotatedChildren, getAnnotation, getAnnotation, getAnnotations, getComments, getDirectChildren, getDocComment, getElements, getMetadata, getMetadataKeys, getOriginalSourceFragment, getParent, getParent, getPath, getPosition, getReferencedTypes, getRoleInParent, getShortRepresentation, getValueByRole, hasAnnotation, hasParent, isImplicit, isParentInitialized, prettyprint, putMetadata, removeAnnotation, removeComment, replace, replace, setAllMetadata, setAnnotations, setComments, setDocComment, setImplicit, setParent, setPosition, setPositions, setValueByRole, toString, toStringDebug, updateAllParentsBelow
Methods inherited from interface spoon.reflect.declaration.CtNamedElement
getSimpleName, setSimpleName
Methods inherited from interface spoon.reflect.visitor.chain.CtQueryable
filterChildren, map, map
Methods inherited from interface spoon.processing.FactoryAccessor
getFactory, setFactory
-
Constructor Details
-
CtParameterImpl
public CtParameterImpl()
-
-
Method Details
-
accept
Description copied from interface:CtVisitable
Accepts a visitor- Specified by:
accept
in interfaceCtVisitable
-
getDefaultExpression
Description copied from interface:CtVariable
Gets the initialization expression assigned to the variable (also known as the initializer), when declared.- Specified by:
getDefaultExpression
in interfaceCtVariable<T>
-
getReference
Description copied from interface:CtNamedElement
Returns the corresponding reference.- Specified by:
getReference
in interfaceCtNamedElement
- Specified by:
getReference
in interfaceCtParameter<T>
- Specified by:
getReference
in interfaceCtVariable<T>
- Overrides:
getReference
in classCtNamedElementImpl
-
getType
Description copied from interface:CtTypedElement
Gets this element's type.- Specified by:
getType
in interfaceCtTypedElement<T>
-
setDefaultExpression
Description copied from interface:CtVariable
Sets the initialization expression assigned to the variable, when declared.- Specified by:
setDefaultExpression
in interfaceCtParameter<T>
- Specified by:
setDefaultExpression
in interfaceCtVariable<T>
-
isPartOfJointDeclaration
public boolean isPartOfJointDeclaration()Description copied from interface:CtVariable
Returns true it the variable (field, localvariable) is jointly declared with a share type Eg int a,b; Warning: is computed on demand- Specified by:
isPartOfJointDeclaration
in interfaceCtVariable<T>
-
isInferred
public boolean isInferred()Description copied from interface:CtParameter
Returns true if this parameter is a lambda parameter with type defined using the `var` keyword (since Java 11).- Specified by:
isInferred
in interfaceCtParameter<T>
-
setInferred
Description copied from interface:CtParameter
Set to true if this parameter is a lambda parameter with type defined using the `var` keyword. Warning: this method should only be used if compliance level is set to 11 or more.- Specified by:
setInferred
in interfaceCtParameter<T>
-
setType
Description copied from interface:CtTypedElement
Sets this element's type.- Specified by:
setType
in interfaceCtTypedElement<T>
-
isVarArgs
public boolean isVarArgs()Description copied from interface:CtParameter
Returns true if this parameter accepts a variable number of arguments (must be the last parameter ofCtExecutable.getParameters()
).- Specified by:
isVarArgs
in interfaceCtParameter<T>
-
setVarArgs
Description copied from interface:CtParameter
Sets this parameter to have varargs.- Specified by:
setVarArgs
in interfaceCtParameter<T>
-
getModifiers
Description copied from interface:CtModifiable
Returns the modifiers of this element, excluding annotations. Implicit modifiers, such as thepublic
andstatic
modifiers of interface members, are included.- Specified by:
getModifiers
in interfaceCtModifiable
- Returns:
- the modifiers of this declaration in undefined order; an empty set if there are none
-
hasModifier
Description copied from interface:CtModifiable
Tells if this element contains the given modifier.- Specified by:
hasModifier
in interfaceCtModifiable
- Parameters:
modifier
- to search- Returns:
true
if this element contain the modifier
-
setModifiers
Description copied from interface:CtModifiable
Sets the modifiers.- Specified by:
setModifiers
in interfaceCtModifiable
-
addModifier
Description copied from interface:CtModifiable
add a modifier- Specified by:
addModifier
in interfaceCtModifiable
-
removeModifier
Description copied from interface:CtModifiable
remove a modifier- Specified by:
removeModifier
in interfaceCtModifiable
-
setVisibility
Description copied from interface:CtModifiable
Sets the visibility of this modifiable element (replaces old visibility).- Specified by:
setVisibility
in interfaceCtModifiable
-
getVisibility
Description copied from interface:CtModifiable
Gets the visibility of this modifiable element.- Specified by:
getVisibility
in interfaceCtModifiable
-
getParent
Description copied from interface:CtElement
Gets the parent of current reference.- Specified by:
getParent
in interfaceCtElement
- Specified by:
getParent
in interfaceCtParameter<T>
- Overrides:
getParent
in classCtElementImpl
-
getExtendedModifiers
- Specified by:
getExtendedModifiers
in interfaceCtModifiable
- Returns:
- the set of extended modifiers (those incl. implicit).
-
setExtendedModifiers
- Specified by:
setExtendedModifiers
in interfaceCtModifiable
-
isShadow
public boolean isShadow()Description copied from interface:CtShadowable
When an element isn't present in the factory (created in another factory), this element is considered as "shadow". e.g., a shadow element can be a CtType of java.lang.Class built when we callCtTypeReference.getTypeDeclaration()
on a reference of java.lang.Class.- Specified by:
isShadow
in interfaceCtShadowable
- Returns:
- true if the element is a shadow element, otherwise false.
-
setShadow
Description copied from interface:CtShadowable
Marks an element as shadow. To know what is a shadow element, see the javadoc ofCtShadowable.isShadow()
.- Specified by:
setShadow
in interfaceCtShadowable
-
clone
Description copied from interface:CtElement
Clone the element which calls this method in a new object. Note that that references are kept as is, and thus, so if you clone whole classes or methods, some parts of the cloned element (eg executable references) may still point to the initial element. In this case, consider using methodsRefactoring.copyType(CtType)
andRefactoring.copyMethod(CtMethod)
instead which does additional work beyond cloning.- Specified by:
clone
in interfaceCtElement
- Specified by:
clone
in interfaceCtNamedElement
- Specified by:
clone
in interfaceCtParameter<T>
- Overrides:
clone
in classCtNamedElementImpl
-
isPublic
public boolean isPublic()Description copied from interface:CtModifiable
Returns true if it contains a public modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isPublic
in interfaceCtModifiable
-
isPrivate
public boolean isPrivate()Description copied from interface:CtModifiable
Returns true if it contains a private modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isPrivate
in interfaceCtModifiable
-
isProtected
public boolean isProtected()Description copied from interface:CtModifiable
Returns true if it contains a protected modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isProtected
in interfaceCtModifiable
-
isFinal
public boolean isFinal()Description copied from interface:CtModifiable
Returns true if it contains a final modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isFinal
in interfaceCtModifiable
-
isStatic
public boolean isStatic()Description copied from interface:CtModifiable
Returns true if it contains a static modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isStatic
in interfaceCtModifiable
-
isAbstract
public boolean isAbstract()Description copied from interface:CtModifiable
Returns true if it contains an abstract modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isAbstract
in interfaceCtModifiable
-
isTransient
public boolean isTransient()Description copied from interface:CtModifiable
Returns true if it contains a transient modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isTransient
in interfaceCtModifiable
-
isVolatile
public boolean isVolatile()Description copied from interface:CtModifiable
Returns true if it contains a volatile modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isVolatile
in interfaceCtModifiable
-
isSynchronized
public boolean isSynchronized()Description copied from interface:CtModifiable
Returns true if it contains a synchronized modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isSynchronized
in interfaceCtModifiable
-
isNative
public boolean isNative()Description copied from interface:CtModifiable
Returns true if it contains a native modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isNative
in interfaceCtModifiable
-
isStrictfp
public boolean isStrictfp()Description copied from interface:CtModifiable
Returns true if it contains a strictfp modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isStrictfp
in interfaceCtModifiable
-