public class CtAnnotationImpl<A extends java.lang.annotation.Annotation> extends CtExpressionImpl<A> implements CtAnnotation<A>
CtAnnotation
.ERROR_MESSAGE_TO_STRING, factory, LOGGER, parent
Constructor and Description |
---|
CtAnnotationImpl() |
Modifier and Type | Method and Description |
---|---|
void |
accept(CtVisitor visitor)
Accepts a visitor
|
<T extends CtAnnotation<A>> |
addValue(java.lang.String elementName,
CtAnnotation<?> value)
Adds a new key-annotation pair for this annotation.
|
<T extends CtAnnotation<A>> |
addValue(java.lang.String elementName,
CtFieldAccess<?> value)
Adds a new key-field access pair for this annotation.
|
<T extends CtAnnotation<A>> |
addValue(java.lang.String elementName,
CtLiteral<?> value)
Adds a new key-literal pair for this annotation.
|
<T extends CtAnnotation<A>> |
addValue(java.lang.String elementName,
CtNewArray<? extends CtExpression> value)
Adds a new key-array pair for this annotation.
|
<T extends CtAnnotation<A>> |
addValue(java.lang.String elementName,
java.lang.Object value)
Adds a new key-value pair for this annotation
|
CtAnnotation<A> |
clone()
Clone the element which calls this method in a new object.
|
A |
getActualAnnotation()
Returns the actual annotation (a dynamic proxy for this element).
|
java.util.Map<java.lang.String,CtExpression> |
getAllValues()
Get all values of
CtAnnotation.getValues() , plus the default ones defined in the annotation type. |
CtElement |
getAnnotatedElement()
Returns the element which is annotated by this annotation.
|
CtAnnotatedElementType |
getAnnotatedElementType()
Returns the type of the element which is annotated by this annotation.
|
CtTypeReference<A> |
getAnnotationType()
Returns the annotation type of this annotation.
|
java.util.Map<java.lang.String,java.lang.Object> |
getElementValues() |
java.util.List<CtTypeReference<?>> |
getTypeCasts()
Returns the type casts if any.
|
<T extends CtExpression> |
getValue(java.lang.String key)
Gets a value, as a CtExpression, for a given key without any conversion.
|
int |
getValueAsInt(java.lang.String key)
Returns the actual value of an annotation property, as an integer (utility method)
|
java.lang.Object |
getValueAsObject(java.lang.String key)
Returns the actual value of an annotation property
|
java.lang.String |
getValueAsString(java.lang.String key)
Returns the actual value of an annotation property, as a String (utility method)
|
java.util.Map<java.lang.String,CtExpression> |
getValues()
Returns this annotation's elements and their values.
|
<T extends CtExpression> |
getWrappedValue(java.lang.String key)
Gets a value for a given key and try to fix its type based on the
annotation type.
|
boolean |
isShadow()
When an element isn't present in the factory (created in another factory),
this element is considered as "shadow".
|
<T extends CtAnnotation<A>> |
setAnnotationType(CtTypeReference<? extends java.lang.annotation.Annotation> annotationType)
Sets the annotation's type.
|
<T extends CtAnnotation<A>> |
setElementValues(java.util.Map<java.lang.String,java.lang.Object> values)
Set's this annotation's element names and their values.
|
<E extends CtShadowable> |
setShadow(boolean isShadow)
Marks an element as shadow.
|
<C extends CtExpression<A>> |
setTypeCasts(java.util.List<CtTypeReference<?>> casts)
Sets the type casts.
|
<T extends CtAnnotation<A>> |
setValues(java.util.Map<java.lang.String,CtExpression> values)
Set's this annotation's element names and their values.
|
addTypeCast, getType, S, setType
partiallyEvaluate
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, 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
finalize, getClass, notify, notifyAll, wait, wait, wait
getAnnotatedElementTypeForCtElement
addTypeCast
partiallyEvaluate
getType, setType
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, isImplicit, isParentInitialized, prettyprint, putMetadata, removeAnnotation, removeComment, replace, replace, setAllMetadata, setAnnotations, setComments, setDocComment, setImplicit, setParent, setPosition, setPositions, setValueByRole, toString, toStringDebug, updateAllParentsBelow
getFactory, setFactory
filterChildren, map, map
S
public void accept(CtVisitor visitor)
CtVisitable
accept
in interface CtVisitable
public <T extends CtAnnotation<A>> T addValue(java.lang.String elementName, java.lang.Object value)
CtAnnotation
addValue
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
public <T extends CtAnnotation<A>> T addValue(java.lang.String elementName, CtLiteral<?> value)
CtAnnotation
addValue
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
public <T extends CtAnnotation<A>> T addValue(java.lang.String elementName, CtNewArray<? extends CtExpression> value)
CtAnnotation
addValue
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
public <T extends CtAnnotation<A>> T addValue(java.lang.String elementName, CtFieldAccess<?> value)
CtAnnotation
addValue
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
public <T extends CtAnnotation<A>> T addValue(java.lang.String elementName, CtAnnotation<?> value)
CtAnnotation
addValue
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
public CtTypeReference<A> getAnnotationType()
CtAnnotation
getAnnotationType
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
public <T extends CtExpression> T getValue(java.lang.String key)
CtAnnotation
CtAnnotation.getValueAsObject(String)
and similar methods.
Note that this value type does not necessarily corresponds to the annotation
type member. For example, in case the annotation type expect an array of Object,
and a single value is given, Spoon will return only the object without the CtNewArray.
If you want to get a type closer to the annotation type one, see CtAnnotation.getWrappedValue(String)
.getValue
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
key
- Name of searched value.public int getValueAsInt(java.lang.String key)
CtAnnotation
getValueAsInt
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
public java.lang.String getValueAsString(java.lang.String key)
CtAnnotation
getValueAsString
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
public java.lang.Object getValueAsObject(java.lang.String key)
CtAnnotation
getValueAsObject
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
public <T extends CtExpression> T getWrappedValue(java.lang.String key)
CtAnnotation
getWrappedValue
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
key
- Name of searched value.public java.util.Map<java.lang.String,java.lang.Object> getElementValues()
public java.util.Map<java.lang.String,CtExpression> getValues()
CtAnnotation
getValues
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
public java.util.Map<java.lang.String,CtExpression> getAllValues()
CtAnnotation
CtAnnotation.getValues()
, plus the default ones defined in the annotation type.getAllValues
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
public <T extends CtAnnotation<A>> T setAnnotationType(CtTypeReference<? extends java.lang.annotation.Annotation> annotationType)
CtAnnotation
setAnnotationType
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
annotationType
- reference to the type of this annotationpublic <T extends CtAnnotation<A>> T setElementValues(java.util.Map<java.lang.String,java.lang.Object> values)
CtAnnotation
CtTypeReference
.setElementValues
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
public <T extends CtAnnotation<A>> T setValues(java.util.Map<java.lang.String,CtExpression> values)
CtAnnotation
setValues
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
public CtElement getAnnotatedElement()
CtAnnotation
getAnnotatedElement
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
CtElement
public CtAnnotatedElementType getAnnotatedElementType()
CtAnnotation
getAnnotatedElementType
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
CtAnnotatedElementType
public A getActualAnnotation()
CtAnnotation
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.
getActualAnnotation
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
public boolean isShadow()
CtShadowable
CtTypeReference.getTypeDeclaration()
on a reference of java.lang.Class.isShadow
in interface CtShadowable
public <E extends CtShadowable> E setShadow(boolean isShadow)
CtShadowable
CtShadowable.isShadow()
.setShadow
in interface CtShadowable
public CtAnnotation<A> clone()
CtElement
Refactoring.copyType(CtType)
and Refactoring.copyMethod(CtMethod)
instead which does additional work beyond cloning.clone
in interface CtCodeElement
clone
in interface CtExpression<A extends java.lang.annotation.Annotation>
clone
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
clone
in interface CtElement
clone
in class CtExpressionImpl<A extends java.lang.annotation.Annotation>
public java.util.List<CtTypeReference<?>> getTypeCasts()
CtExpression
getTypeCasts
in interface CtExpression<A extends java.lang.annotation.Annotation>
getTypeCasts
in class CtExpressionImpl<A extends java.lang.annotation.Annotation>
public <C extends CtExpression<A>> C setTypeCasts(java.util.List<CtTypeReference<?>> casts)
CtExpression
setTypeCasts
in interface CtExpression<A extends java.lang.annotation.Annotation>
setTypeCasts
in interface CtAnnotation<A extends java.lang.annotation.Annotation>
setTypeCasts
in class CtExpressionImpl<A extends java.lang.annotation.Annotation>
Copyright © 2007–2021 Inria. All rights reserved.