Debian Codegraph @

api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/FieldConfig.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.FieldInfo;
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 field.
21 * Note that the field 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 FieldConfig extends DeclarationConfig {
28 /**
29 * Returns the {@link FieldInfo} corresponding to this transformed field.
30 *
31 * @return the {@link FieldInfo} corresponding to this transformed field, never {@code null}
32 */
33 @Override
34 FieldInfo info();
35
36 /**
37 * Adds a marker annotation of given type to this field.
38 * Does not allow configuring annotation members.
39 *
40 * @param annotationType the annotation type, must not be {@code null}
41 * @return this configurator object, to allow fluent usage
42 */
43 @Override
44 FieldConfig addAnnotation(Class<? extends Annotation> annotationType);
45
46 /**
47 * Adds given annotation to this field. The {@link AnnotationInfo} can be obtained
48 * from an annotation target, or constructed from scratch using {@link AnnotationBuilder}.
49 *
50 * @param annotation the annotation to add to this field, must not be {@code null}
51 * @return this configurator object, to allow fluent usage
52 */
53 @Override
54 FieldConfig addAnnotation(AnnotationInfo annotation);
55
56 /**
57 * Adds given annotation to this field. The annotation instance is typically
58 * a subclass of {@link jakarta.enterprise.util.AnnotationLiteral AnnotationLiteral}.
59 *
60 * @param annotation the annotation to add to this field, must not be {@code null}
61 * @return this configurator object, to allow fluent usage
62 */
63 @Override
64 FieldConfig addAnnotation(Annotation annotation);
65
66 /**
67 * Removes all annotations matching given predicate from this field.
68 *
69 * @param predicate an annotation predicate, must not be {@code null}
70 * @return this configurator object, to allow fluent usage
71 */
72 @Override
73 FieldConfig removeAnnotation(Predicate<AnnotationInfo> predicate);
74
75 /**
76 * Removes all annotations from this field.
77 *
78 * @return this configurator object, to allow fluent usage
79 */
80 @Override
81 FieldConfig removeAllAnnotations();
82 }