| 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.ParameterInfo; |
| 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 method parameter. |
| 21 |
* Note that the method parameter 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 ParameterConfig extends DeclarationConfig { |
| 28 |
/** |
| 29 |
* Returns the {@link ParameterInfo} corresponding to this transformed method parameter. |
| 30 |
* |
| 31 |
* @return the {@link ParameterInfo} corresponding to this transformed method parameter, never {@code null} |
| 32 |
*/ |
| 33 |
@Override |
| 34 |
ParameterInfo info(); |
| 35 |
|
| 36 |
/** |
| 37 |
* Adds a marker annotation of given type to this method parameter. |
| 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 |
ParameterConfig addAnnotation(Class<? extends Annotation> annotationType); |
| 45 |
|
| 46 |
/** |
| 47 |
* Adds given annotation to this method parameter. 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 method parameter, must not be {@code null} |
| 51 |
* @return this configurator object, to allow fluent usage |
| 52 |
*/ |
| 53 |
@Override |
| 54 |
ParameterConfig addAnnotation(AnnotationInfo annotation); |
| 55 |
|
| 56 |
/** |
| 57 |
* Adds given annotation to this method parameter. 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 method parameter, must not be {@code null} |
| 61 |
* @return this configurator object, to allow fluent usage |
| 62 |
*/ |
| 63 |
@Override |
| 64 |
ParameterConfig addAnnotation(Annotation annotation); |
| 65 |
|
| 66 |
/** |
| 67 |
* Removes all annotations matching given predicate from this method parameter. |
| 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 |
ParameterConfig removeAnnotation(Predicate<AnnotationInfo> predicate); |
| 74 |
|
| 75 |
/** |
| 76 |
* Removes all annotations from this method parameter. |
| 77 |
* |
| 78 |
* @return this configurator object, to allow fluent usage |
| 79 |
*/ |
| 80 |
@Override |
| 81 |
ParameterConfig removeAllAnnotations(); |
| 82 |
} |