Debian Codegraph @

api/src/main/java/jakarta/enterprise/inject/spi/configurator/AnnotatedParameterConfigurator.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.AnnotatedParameter;
23
24 /**
25 *
26 * This interface is part of the {@link AnnotatedTypeConfigurator} SPI and helps defining an {@link AnnotatedParameter}
27 *
28 * <p>CDI Lite implementations are not required to provide support for Portable Extensions.</p>
29 *
30 * @author Martin Kouba
31 * @author Antoine Sabot-Durand
32 * @since 2.0
33 * @param <T> the class containing the method declaring the parameter
34 */
35 public interface AnnotatedParameterConfigurator<T> {
36
37 /**
38 *
39 * @return the original {@link AnnotatedParameter}
40 */
41 AnnotatedParameter<T> getAnnotated();
42
43 /**
44 * Add an annotation to the parameter.
45 *
46 * @param annotation the annotation to add
47 * @return self
48 */
49 AnnotatedParameterConfigurator<T> add(Annotation annotation);
50
51 /**
52 * Remove annotations that match the specified predicate.
53 *
54 * <p>
55 * Example predicates:
56 * </p>
57 *
58 * <pre>
59 * {@code
60 * // To remove all the annotations:
61 * (a) -> true
62 *
63 * // To remove annotations with a concrete annotation type:
64 * (a) -> a.annotationType().equals(Foo.class)
65 *
66 * // To remove annotation equal to a specified object:
67 * (a) -> a.equals(fooAnnotation)
68 *
69 * // To remove annotations that are considered equivalent for the purposes of typesafe resolution:
70 * (a) -> beanManager.areQualifiersEquivalent(a, fooQualifier)
71 * (a) -> beanManager.areInterceptorBindingsEquivalent(a, fooInterceptorBinding)
72 * }
73 * </pre>
74 *
75 * @param predicate {@link Predicate} used to filter annotations to remove
76 * @return self
77 */
78 AnnotatedParameterConfigurator<T> remove(Predicate<Annotation> predicate);
79
80 /**
81 * Remove all the annotations.
82 *
83 * @return self
84 */
85 default AnnotatedParameterConfigurator<T> removeAll() {
86 return remove((a) -> true);
87 }
88
89 }