Package spoon.reflect.code
Interface CtTypeAccess<A>
- Type Parameters:
A
- Access type of the expression.
- All Superinterfaces:
Cloneable
,CtCodeElement
,CtElement
,CtExpression<Void>
,CtQueryable
,CtTypedElement<Void>
,CtVisitable
,FactoryAccessor
,Serializable
,SourcePositionHolder
,TemplateParameter<Void>
- All Known Implementing Classes:
CtTypeAccessImpl
This code element represents a type reference usable as an expression.
It is used in particular for static accesses, Java 8 method references, instanceof binary expressions and ".class".
// access to static field java.io.PrintStream ps = System.out;
// call to static method Class.forName("Foo")
// method reference java.util.function.Supplier p = Object::new;
// instanceof test boolean x = new Object() instanceof Integer // Integer is represented as an access to type Integer
// fake field "class" Class x = Number.class
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Clone the element which calls this method in a new object.Returns type represented and contained in the type access.getType()
Returns always VOID.boolean
Returns true if this element is not present in the code (automatically added by the Java compiler or inferred when the model is built).<C extends CtTypeAccess<A>>
CsetAccessedType(CtTypeReference<A> accessedType)
Set the accessed type.<E extends CtElement>
EsetImplicit(boolean implicit)
CallsgetAccessedType()
.setImplicit()<C extends CtTypedElement>
CsetType(CtTypeReference type)
Sets this element's type.Methods inherited from interface spoon.reflect.code.CtCodeElement
partiallyEvaluate
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, getParent, getPath, getPosition, getReferencedTypes, getRoleInParent, getShortRepresentation, getValueByRole, hasAnnotation, hasParent, isParentInitialized, prettyprint, putMetadata, removeAnnotation, removeComment, replace, replace, setAllMetadata, setAnnotations, setComments, setDocComment, setParent, setPosition, setPositions, setValueByRole, toString, toStringDebug, updateAllParentsBelow
Methods inherited from interface spoon.reflect.code.CtExpression
addTypeCast, getTypeCasts, setTypeCasts
Methods inherited from interface spoon.reflect.visitor.chain.CtQueryable
filterChildren, map, map
Methods inherited from interface spoon.reflect.visitor.CtVisitable
accept
Methods inherited from interface spoon.processing.FactoryAccessor
getFactory, setFactory
Methods inherited from interface spoon.template.TemplateParameter
S
-
Method Details
-
getAccessedType
CtTypeReference<A> getAccessedType()Returns type represented and contained in the type access.- Returns:
- CtTypeReference.
-
setAccessedType
Set the accessed type.- Parameters:
accessedType
- CtTypeReference.
-
getType
CtTypeReference<Void> getType()Returns always VOID.- Specified by:
getType
in interfaceCtTypedElement<A>
- See Also:
to get the accessed type.
-
setType
Description copied from interface:CtTypedElement
Sets this element's type.- Specified by:
setType
in interfaceCtTypedElement<A>
-
isImplicit
boolean isImplicit()Description copied from interface:CtElement
Returns true if this element is not present in the code (automatically added by the Java compiler or inferred when the model is built). Consequently, implicit elements are not pretty-printed and have no position.- Specified by:
isImplicit
in interfaceCtElement
- Returns:
getAccessedType()
.isImplicit()
-
setImplicit
CallsgetAccessedType()
.setImplicit()- Specified by:
setImplicit
in interfaceCtElement
-
clone
CtTypeAccess<A> 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 interfaceCtCodeElement
- Specified by:
clone
in interfaceCtElement
- Specified by:
clone
in interfaceCtExpression<A>
-