Interface NodeWithAnnotations<N extends Node>

    • Method Detail

      • tryAddImportToParentCompilationUnit

        void tryAddImportToParentCompilationUnit​(Class<?> clazz)
      • setAnnotation

        default N setAnnotation​(int i,
                                AnnotationExpr element)
      • addAnnotation

        default N addAnnotation​(String name)
        Annotates this
        Parameters:
        name - the name of the annotation
        Returns:
        this
      • addAnnotation

        default N addAnnotation​(Class<? extends Annotation> clazz)
        Annotates this node and automatically add the import
        Parameters:
        clazz - the class of the annotation
        Returns:
        this
      • addMarkerAnnotation

        default N addMarkerAnnotation​(String name)
        Annotates this with a marker annotation
        Parameters:
        name - the name of the annotation
        Returns:
        this
      • addMarkerAnnotation

        default N addMarkerAnnotation​(Class<? extends Annotation> clazz)
        Annotates this with a marker annotation and automatically add the import
        Parameters:
        clazz - the class of the annotation
        Returns:
        this
      • addSingleMemberAnnotation

        default N addSingleMemberAnnotation​(String name,
                                            Expression expression)
        Annotates this with a single member annotation
        Parameters:
        name - the name of the annotation
        expression - the part between ()
        Returns:
        this
      • addSingleMemberAnnotation

        default N addSingleMemberAnnotation​(Class<? extends Annotation> clazz,
                                            Expression expression)
        Annotates this with a single member annotation
        Parameters:
        clazz - the class of the annotation
        expression - the part between ()
        Returns:
        this
      • addSingleMemberAnnotation

        default N addSingleMemberAnnotation​(String name,
                                            String value)
        Annotates this with a single member annotation
        Parameters:
        name - the name of the annotation
        value - the value, don't forget to add \"\" for a string value
        Returns:
        this
      • addSingleMemberAnnotation

        default N addSingleMemberAnnotation​(Class<? extends Annotation> clazz,
                                            String value)
        Annotates this with a single member annotation and automatically add the import
        Parameters:
        clazz - the class of the annotation
        value - the value, don't forget to add \"\" for a string value
        Returns:
        this
      • isAnnotationPresent

        default boolean isAnnotationPresent​(String annotationName)
        Check whether an annotation with this name is present on this element
        Parameters:
        annotationName - the name of the annotation
        Returns:
        true if found, false if not
      • isAnnotationPresent

        default boolean isAnnotationPresent​(Class<? extends Annotation> annotationClass)
        Check whether an annotation with this class is present on this element
        Parameters:
        annotationClass - the class of the annotation
        Returns:
        true if found, false if not
      • getAnnotationByName

        default Optional<AnnotationExpr> getAnnotationByName​(String annotationName)
        Try to find an annotation by its name
        Parameters:
        annotationName - the name of the annotation
      • getAnnotationByClass

        default Optional<AnnotationExpr> getAnnotationByClass​(Class<? extends Annotation> annotationClass)
        Try to find an annotation by its class
        Parameters:
        annotationClass - the class of the annotation