Package spoon.reflect.factory
Class AnnotationFactory
- java.lang.Object
-
- spoon.reflect.factory.SubFactory
-
- spoon.reflect.factory.TypeFactory
-
- spoon.reflect.factory.AnnotationFactory
-
public class AnnotationFactory extends TypeFactory
TheCtAnnotationType
sub-factory.
-
-
Field Summary
-
Fields inherited from class spoon.reflect.factory.TypeFactory
BOOLEAN, BOOLEAN_PRIMITIVE, BYTE, BYTE_PRIMITIVE, CHARACTER, CHARACTER_PRIMITIVE, COLLECTION, DATE, DOUBLE, DOUBLE_PRIMITIVE, ENUM, FLOAT, FLOAT_PRIMITIVE, INTEGER, INTEGER_PRIMITIVE, ITERABLE, LIST, LONG, LONG_PRIMITIVE, MAP, NULL_TYPE, OBJECT, OMITTED_TYPE_ARG_TYPE, SET, SHORT, SHORT_PRIMITIVE, STRING, VOID, VOID_PRIMITIVE
-
Fields inherited from class spoon.reflect.factory.SubFactory
factory
-
-
Constructor Summary
Constructors Constructor Description AnnotationFactory(Factory factory)
Creates an annotation sub-factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <A extends Annotation>
CtAnnotation<A>annotate(CtElement element, Class<A> annotationType)
Adds an annotation to an element.<A extends Annotation>
CtAnnotation<A>annotate(CtElement element, Class<A> annotationType, String annotationElementName, Object value)
Creates/updates an element's annotation value.<A extends Annotation>
CtAnnotation<A>annotate(CtElement element, CtTypeReference<A> annotationType)
Adds an annotation to an element.<A extends Annotation>
CtAnnotation<A>annotate(CtElement element, CtTypeReference<A> annotationType, String annotationElementName, Object value)
Creates/updates an element's annotation value.CtAnnotationType<?>
create(String qualifiedName)
Creates an annotation type.<T extends Annotation>
CtAnnotationType<?>create(CtPackage owner, String simpleName)
Creates an annotation type.<T extends Annotation>
CtType<T>getAnnotationType(String qualifiedName)
Gets a annotation type from its name.-
Methods inherited from class spoon.reflect.factory.TypeFactory
booleanPrimitiveType, booleanType, bytePrimitiveType, byteType, characterPrimitiveType, characterType, createArrayReference, createArrayReference, createArrayReference, createArrayReference, createImport, createIntersectionTypeReferenceWithBounds, createReference, createReference, createReference, createReference, createReference, createReference, createReferences, createSimplyQualifiedReference, createTypeAdapter, createTypeMemberWildcardImportReference, createTypeParameterReference, createUnresolvedImport, dateType, doublePrimitiveType, doubleType, floatPrimitiveType, floatType, get, get, getAll, getAll, getDeclaringTypeName, getDefaultBoundingType, getPackageName, getSimpleName, hasInnerType, hasPackage, integerPrimitiveType, integerType, longPrimitiveType, longType, nullType, objectType, shortPrimitiveType, shortType, stringType, voidPrimitiveType, voidType
-
-
-
-
Constructor Detail
-
AnnotationFactory
public AnnotationFactory(Factory factory)
Creates an annotation sub-factory.- Parameters:
factory
- the parent factory
-
-
Method Detail
-
create
public <T extends Annotation> CtAnnotationType<?> create(CtPackage owner, String simpleName)
Creates an annotation type.- Parameters:
owner
- the package of the annotation typesimpleName
- the name of annotation
-
create
public CtAnnotationType<?> create(String qualifiedName)
Creates an annotation type.- Parameters:
qualifiedName
- the fully qualified name of the annotation type.
-
getAnnotationType
public <T extends Annotation> CtType<T> getAnnotationType(String qualifiedName)
Gets a annotation type from its name.
-
annotate
public <A extends Annotation> CtAnnotation<A> annotate(CtElement element, Class<A> annotationType, String annotationElementName, Object value)
Creates/updates an element's annotation value.- Parameters:
element
- the program element to annotateannotationType
- the annotation typeannotationElementName
- the annotation element namevalue
- the value of the annotation element- Returns:
- the created/updated annotation
-
annotate
public <A extends Annotation> CtAnnotation<A> annotate(CtElement element, CtTypeReference<A> annotationType, String annotationElementName, Object value)
Creates/updates an element's annotation value.- Parameters:
element
- the program element to annotateannotationType
- the annotation typeannotationElementName
- the annotation element namevalue
- the value of the annotation element- Returns:
- the created/updated annotation
-
annotate
public <A extends Annotation> CtAnnotation<A> annotate(CtElement element, Class<A> annotationType)
Adds an annotation to an element.- Parameters:
element
- the program element to annotateannotationType
- the annotation type- Returns:
- the concerned annotation
-
annotate
public <A extends Annotation> CtAnnotation<A> annotate(CtElement element, CtTypeReference<A> annotationType)
Adds an annotation to an element.- Parameters:
element
- the program element to annotateannotationType
- the annotation type- Returns:
- the concerned annotation
-
-