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 java.lang.annotation.Annotation> CtAnnotationType<?> create​(CtPackage owner,
                                                                                      java.lang.String simpleName)
        Creates an annotation type.
        Parameters:
        owner - the package of the annotation type
        simpleName - the name of annotation
      • create

        public CtAnnotationType<?> create​(java.lang.String qualifiedName)
        Creates an annotation type.
        Parameters:
        qualifiedName - the fully qualified name of the annotation type.
      • getAnnotationType

        public <T extends java.lang.annotation.Annotation> CtType<T> getAnnotationType​(java.lang.String qualifiedName)
        Gets a annotation type from its name.
      • annotate

        public <A extends java.lang.annotation.Annotation> CtAnnotation<A> annotate​(CtElement element,
                                                                                    java.lang.Class<A> annotationType,
                                                                                    java.lang.String annotationElementName,
                                                                                    java.lang.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 java.lang.annotation.Annotation> CtAnnotation<A> annotate​(CtElement element,
                                                                                    CtTypeReference<A> annotationType,
                                                                                    java.lang.String annotationElementName,
                                                                                    java.lang.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 java.lang.annotation.Annotation> CtAnnotation<A> annotate​(CtElement element,
                                                                                    java.lang.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 java.lang.annotation.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