Class AnnotationFactory

    • Constructor Detail

      • AnnotationFactory

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

      • create

        public <T extends AnnotationCtAnnotationType<?> 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 AnnotationCtType<T> getAnnotationType​(String qualifiedName)
        Gets a annotation type from its name.
      • annotate

        public <A extends AnnotationCtAnnotation<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 AnnotationCtAnnotation<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 AnnotationCtAnnotation<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 AnnotationCtAnnotation<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