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.booleanReturns 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
partiallyEvaluateMethods 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, updateAllParentsBelowMethods inherited from interface spoon.reflect.code.CtExpression
addTypeCast, getTypeCasts, setTypeCastsMethods inherited from interface spoon.reflect.visitor.chain.CtQueryable
filterChildren, map, mapMethods inherited from interface spoon.reflect.visitor.CtVisitable
acceptMethods inherited from interface spoon.processing.FactoryAccessor
getFactory, setFactoryMethods 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:
getTypein interfaceCtTypedElement<A>- See Also:
-
setType
Description copied from interface:CtTypedElementSets this element's type.- Specified by:
setTypein interfaceCtTypedElement<A>
-
isImplicit
boolean isImplicit()Description copied from interface:CtElementReturns 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:
isImplicitin interfaceCtElement- Returns:
getAccessedType().isImplicit()
-
setImplicit
CallsgetAccessedType().setImplicit()- Specified by:
setImplicitin interfaceCtElement
-
clone
CtTypeAccess<A> clone()Description copied from interface:CtElementClone 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:
clonein interfaceCtCodeElement- Specified by:
clonein interfaceCtElement- Specified by:
clonein interfaceCtExpression<A>- Returns:
- a clone of this element. All children are cloned, but the parent of the returned clone is set to null.
-