public interface CtElement extends FactoryAccessor, Comparable<CtElement>
Modifier and Type | Method and Description |
---|---|
void |
accept(CtVisitor visitor)
Accepts a visitor.
|
boolean |
addAnnotation(CtAnnotation<? extends Annotation> annotation)
Add an annotation for this element
|
<E extends CtElement> |
getAnnotatedChildren(Class<? extends Annotation> annotationType)
Gets the child elements annotated with the given annotation type's
instances.
|
<A extends Annotation> |
getAnnotation(Class<A> annotationType)
Searches for an annotation (proxy) of the given class that annotates the
current element.
|
<A extends Annotation> |
getAnnotation(CtTypeReference<A> annotationType)
Gets the annotation element for a given annotation type.
|
List<CtAnnotation<? extends Annotation>> |
getAnnotations()
Returns the annotations that are present on this element.
|
String |
getDocComment()
Returns the text of the documentation ("javadoc") comment of this
element.
|
<E extends CtElement> |
getElements(Filter<E> filter) |
CtElement |
getParent()
Gets the parent of current element, which can be null.
|
<P extends CtElement> |
getParent(Class<P> parentType)
Gets the first parent that matches the given type.
|
SourcePosition |
getPosition()
Gets the position of this element in input source files
|
Set<CtTypeReference<?>> |
getReferencedTypes()
Calculates and returns the set of all the types referenced by this
element (and sub-elements in the AST).
|
<T extends CtReference> |
getReferences(ReferenceFilter<T> filter) |
String |
getSignature()
Gets the signature of the element.
|
boolean |
hasParent(CtElement candidate)
Tells if the given element is a direct or indirect parent.
|
boolean |
isImplicit()
Returns true if this element is implicit and automatically added by the
Java compiler.
|
boolean |
isParentInitialized()
Tells if this parent has been initialized.
|
boolean |
isRootElement()
Tells if this element is a root of the element tree (and thus has no
parent, which is different from being not initialized).
|
boolean |
removeAnnotation(CtAnnotation<? extends Annotation> annotation)
Remove an annotation for this element
|
void |
replace(CtElement element)
Replaces this element by another one.
|
void |
setAnnotations(List<CtAnnotation<? extends Annotation>> annotation)
Sets the annotations for this element.
|
void |
setDocComment(String docComment)
Sets the text of the documentation ("javadoc") comment of this
declaration.
|
void |
setImplicit(boolean b)
Sets this element to be implicit (will not be printed).
|
void |
setParent(CtElement element)
Manually sets the parent element of the current element.
|
void |
setPosition(SourcePosition position)
Sets the position in the Java source file.
|
void |
setPositions(SourcePosition position)
Sets the position of this element and all its children element.
|
void |
setRootElement(boolean rootElement)
Sets the root element flag to this element.
|
void |
updateAllParentsBelow()
Calculates and sets all the parents below this element.
|
getFactory, setFactory
compareTo
void accept(CtVisitor visitor)
visitor
- to accept<A extends Annotation> A getAnnotation(Class<A> annotationType)
NOTE: before using an annotation proxy, you have to make sure that all
the types referenced by the annotation have been compiled and are in the
classpath so that accessed values can be converted into the actual types.
Otherwise, use getAnnotation(CtTypeReference)
.
A
- the annotation's typeannotationType
- the annotation's class<A extends Annotation> CtAnnotation<A> getAnnotation(CtTypeReference<A> annotationType)
annotationType
- the annotation typeList<CtAnnotation<? extends Annotation>> getAnnotations()
String getDocComment()
CtElement getParent() throws ParentNotInitializedException
updateAllParentsBelow()
.ParentNotInitializedException
- when the parent of this element is not initializedboolean isParentInitialized()
boolean isRootElement()
getParent()
will return null without throwing
an exception.void setRootElement(boolean rootElement)
String getSignature()
<P extends CtElement> P getParent(Class<P> parentType) throws ParentNotInitializedException
ParentNotInitializedException
boolean hasParent(CtElement candidate) throws ParentNotInitializedException
ParentNotInitializedException
SourcePosition getPosition()
void replace(CtElement element)
boolean addAnnotation(CtAnnotation<? extends Annotation> annotation)
annotation
- boolean removeAnnotation(CtAnnotation<? extends Annotation> annotation)
annotation
- void setDocComment(String docComment)
void setParent(CtElement element)
updateAllParentsBelow()
.element
- parentvoid updateAllParentsBelow()
void setPosition(SourcePosition position)
position
- of this element in the input source files<E extends CtElement> List<E> getAnnotatedChildren(Class<? extends Annotation> annotationType)
E
- the element's typeannotationType
- the annotation typeboolean isImplicit()
void setImplicit(boolean b)
Set<CtTypeReference<?>> getReferencedTypes()
<E extends CtElement> List<E> getElements(Filter<E> filter)
filter
- <T extends CtReference> List<T> getReferences(ReferenceFilter<T> filter)
filter
- void setPositions(SourcePosition position)
position
- of this element and all children in the input source filevoid setAnnotations(List<CtAnnotation<? extends Annotation>> annotation)
Copyright © 2007–2014 Inria. All rights reserved.