Debian Codegraph @

api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/DeclarationConfig.java

raw
1 /*
2 * Copyright (c) 2021 Red Hat and others
3 *
4 * This program and the accompanying materials are made available under the
5 * Apache Software License 2.0 which is available at:
6 * https://www.apache.org/licenses/LICENSE-2.0.
7 *
8 * SPDX-License-Identifier: Apache-2.0
9 */
10
11 package jakarta.enterprise.inject.build.compatible.spi;
12
13 import jakarta.enterprise.lang.model.AnnotationInfo;
14 import jakarta.enterprise.lang.model.declarations.DeclarationInfo;
15
16 import java.lang.annotation.Annotation;
17 import java.util.function.Predicate;
18
19 /**
20 * Allows adding annotations to and removing annotations from a declaration.
21 * Note that the declaration is not physically altered, the modifications
22 * are only seen by the CDI container.
23 *
24 * @see Enhancement
25 * @since 4.0
26 */
27 public interface DeclarationConfig {
28 /**
29 * Returns the {@link DeclarationInfo} corresponding to this transformed declaration.
30 *
31 * @return the {@link DeclarationInfo} corresponding to this transformed declaration, never {@code null}
32 */
33 DeclarationInfo info();
34
35 /**
36 * Adds a marker annotation of given type to this declaration.
37 * Does not allow configuring annotation members.
38 *
39 * @param annotationType the annotation type, must not be {@code null}
40 * @return this configurator object, to allow fluent usage
41 */
42 DeclarationConfig addAnnotation(Class<? extends Annotation> annotationType);
43
44 /**
45 * Adds given annotation to this declaration. The {@link AnnotationInfo} can be obtained
46 * from an annotation target, or constructed from scratch using {@link AnnotationBuilder}.
47 *
48 * @param annotation the annotation to add to this declaration, must not be {@code null}
49 * @return this configurator object, to allow fluent usage
50 */
51 DeclarationConfig addAnnotation(AnnotationInfo annotation);
52
53 /**
54 * Adds given annotation to this declaration. The annotation instance is typically
55 * a subclass of {@link jakarta.enterprise.util.AnnotationLiteral AnnotationLiteral}.
56 *
57 * @param annotation the annotation to add to this declaration, must not be {@code null}
58 * @return this configurator object, to allow fluent usage
59 */
60 DeclarationConfig addAnnotation(Annotation annotation);
61
62 /**
63 * Removes all annotations matching given predicate from this declaration.
64 *
65 * @param predicate an annotation predicate, must not be {@code null}
66 * @return this configurator object, to allow fluent usage
67 */
68 DeclarationConfig removeAnnotation(Predicate<AnnotationInfo> predicate);
69
70 /**
71 * Removes all annotations from this declaration.
72 *
73 * @return this configurator object, to allow fluent usage
74 */
75 DeclarationConfig removeAllAnnotations();
76 }