Class AnnotationFactory


public class AnnotationFactory extends TypeFactory
The CtAnnotationType sub-factory.
  • Constructor Details

    • AnnotationFactory

      public AnnotationFactory(Factory factory)
      Creates an annotation sub-factory.
      Parameters:
      factory - the parent factory
  • Method Details

    • create

      public <T extends Annotation> CtAnnotationType<?> create(CtPackage owner, String simpleName)
      Creates an annotation type.
      Parameters:
      owner - the package of the annotation type
      simpleName - 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 annotate
      annotationType - the annotation type
      annotationElementName - the annotation element name
      value - 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 annotate
      annotationType - the annotation type
      annotationElementName - the annotation element name
      value - 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 annotate
      annotationType - 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 annotate
      annotationType - the annotation type
      Returns:
      the concerned annotation