Debian Codegraph @

api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/MethodConfig.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.MethodInfo;
15
16 import java.lang.annotation.Annotation;
17 import java.util.List;
18 import java.util.function.Predicate;
19
20 /**
21 * Allows adding annotations to and removing annotations from a method.
22 * Note that the method is not physically altered, the modifications
23 * are only seen by the CDI container.
24 *
25 * @see Enhancement
26 * @since 4.0
27 */
28 public interface MethodConfig extends DeclarationConfig {
29 /**
30 * Returns the {@link MethodInfo} corresponding to this transformed method.
31 *
32 * @return the {@link MethodInfo} corresponding to this transformed method, never {@code null}
33 */
34 @Override
35 MethodInfo info();
36
37 /**
38 * Adds a marker annotation of given type to this method.
39 * Does not allow configuring annotation members.
40 *
41 * @param annotationType the annotation type, must not be {@code null}
42 * @return this configurator object, to allow fluent usage
43 */
44 @Override
45 MethodConfig addAnnotation(Class<? extends Annotation> annotationType);
46
47 /**
48 * Adds given annotation to this method. The {@link AnnotationInfo} can be obtained
49 * from an annotation target, or constructed from scratch using {@link AnnotationBuilder}.
50 *
51 * @param annotation the annotation to add to this method, must not be {@code null}
52 * @return this configurator object, to allow fluent usage
53 */
54 @Override
55 MethodConfig addAnnotation(AnnotationInfo annotation);
56
57 /**
58 * Adds given annotation to this method. The annotation instance is typically
59 * a subclass of {@link jakarta.enterprise.util.AnnotationLiteral AnnotationLiteral}.
60 *
61 * @param annotation the annotation to add to this method, must not be {@code null}
62 * @return this configurator object, to allow fluent usage
63 */
64 @Override
65 MethodConfig addAnnotation(Annotation annotation);
66
67 /**
68 * Removes all annotations matching given predicate from this method.
69 *
70 * @param predicate an annotation predicate, must not be {@code null}
71 * @return this configurator object, to allow fluent usage
72 */
73 @Override
74 MethodConfig removeAnnotation(Predicate<AnnotationInfo> predicate);
75
76 /**
77 * Removes all annotations from this method.
78 *
79 * @return this configurator object, to allow fluent usage
80 */
81 @Override
82 MethodConfig removeAllAnnotations();
83
84 /**
85 * Returns a list of {@link ParameterConfig} objects for each parameter of this method.
86 *
87 * @return immutable list of {@link ParameterConfig} objects, never {@code null}
88 */
89 List<ParameterConfig> parameters();
90 }