All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jakarta.enterprise.inject.build.compatible.spi.DeclarationConfig Maven / Gradle / Ivy

There is a newer version: 4.1.0
Show newest version
package jakarta.enterprise.inject.build.compatible.spi;

import jakarta.enterprise.lang.model.AnnotationInfo;
import jakarta.enterprise.lang.model.declarations.DeclarationInfo;

import java.lang.annotation.Annotation;
import java.util.function.Predicate;

/**
 * Allows adding annotations to and removing annotations from a declaration.
 * Note that the declaration is not physically altered, the modifications
 * are only seen by the CDI container.
 *
 * @see Enhancement
 * @since 4.0
 */
public interface DeclarationConfig {
    /**
     * Returns the {@link DeclarationInfo} corresponding to this transformed declaration.
     *
     * @return the {@link DeclarationInfo} corresponding to this transformed declaration, never {@code null}
     */
    DeclarationInfo info();

    /**
     * Adds a marker annotation of given type to this declaration.
     * Does not allow configuring annotation members.
     *
     * @param annotationType the annotation type, must not be {@code null}
     * @return this configurator object, to allow fluent usage
     */
    DeclarationConfig addAnnotation(Class annotationType);

    /**
     * Adds given annotation to this declaration. The {@link AnnotationInfo} can be obtained
     * from an annotation target, or constructed from scratch using {@link AnnotationBuilder}.
     *
     * @param annotation the annotation to add to this declaration, must not be {@code null}
     * @return this configurator object, to allow fluent usage
     */
    DeclarationConfig addAnnotation(AnnotationInfo annotation);

    /**
     * Adds given annotation to this declaration. The annotation instance is typically
     * a subclass of {@link jakarta.enterprise.util.AnnotationLiteral AnnotationLiteral}.
     *
     * @param annotation the annotation to add to this declaration, must not be {@code null}
     * @return this configurator object, to allow fluent usage
     */
    DeclarationConfig addAnnotation(Annotation annotation);

    /**
     * Removes all annotations matching given predicate from this declaration.
     *
     * @param predicate an annotation predicate, must not be {@code null}
     * @return this configurator object, to allow fluent usage
     */
    DeclarationConfig removeAnnotation(Predicate predicate);

    /**
     * Removes all annotations from this declaration.
     *
     * @return this configurator object, to allow fluent usage
     */
    DeclarationConfig removeAllAnnotations();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy