Debian Codegraph @

api/src/main/java/jakarta/enterprise/inject/spi/configurator/AnnotatedFieldConfigurator.java

raw
1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2016, Red Hat, Inc., and individual contributors
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package jakarta.enterprise.inject.spi.configurator;
18
19 import java.lang.annotation.Annotation;
20 import java.util.function.Predicate;
21
22 import jakarta.enterprise.inject.spi.AnnotatedField;
23
24 /**
25 * This interface is part of the {@link AnnotatedTypeConfigurator} SPI and helps defining an {@link AnnotatedField}
26 *
27 * <p>CDI Lite implementations are not required to provide support for Portable Extensions.</p>
28 *
29 * @author Martin Kouba
30 * @author Antoine Sabot-Durand
31 * @since 2.0
32 * @param <T> the class declaring the field
33 */
34 public interface AnnotatedFieldConfigurator<T> {
35
36 /**
37 *
38 * @return the original {@link AnnotatedField}
39 */
40 AnnotatedField<T> getAnnotated();
41
42 /**
43 * Add an annotation to the field.
44 *
45 * @param annotation the annotation to add
46 * @return self
47 */
48 AnnotatedFieldConfigurator<T> add(Annotation annotation);
49
50 /**
51 * Remove annotations that match the specified predicate.
52 *
53 * <p>
54 * Example predicates:
55 * </p>
56 *
57 * <pre>
58 * {@code
59 * // To remove all the annotations:
60 * (a) -> true
61 *
62 * // To remove annotations with a concrete annotation type:
63 * (a) -> a.annotationType().equals(Foo.class)
64 *
65 * // To remove annotation equal to a specified object:
66 * (a) -> a.equals(fooAnnotation)
67 *
68 * // To remove annotations that are considered equivalent for the purposes of typesafe resolution:
69 * (a) -> beanManager.areQualifiersEquivalent(a, fooQualifier)
70 * (a) -> beanManager.areInterceptorBindingsEquivalent(a, fooInterceptorBinding)
71 * }
72 * </pre>
73 *
74 * @param predicate {@link Predicate} used to filter annotations to remove
75 * @return self
76 */
77 AnnotatedFieldConfigurator<T> remove(Predicate<Annotation> predicate);
78
79 /**
80 * Remove all the annotations.
81 *
82 * @return self
83 */
84 default AnnotatedFieldConfigurator<T> removeAll() {
85 return remove((a) -> true);
86 }
87
88 }