| 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.ClassInfo; |
| 15 |
|
| 16 |
import java.lang.annotation.Annotation; |
| 17 |
import java.util.Collection; |
| 18 |
import java.util.function.Predicate; |
| 19 |
|
| 20 |
/** |
| 21 |
* Allows adding annotations to and removing annotations from a class. |
| 22 |
* Note that the class 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 ClassConfig extends DeclarationConfig { |
| 29 |
/** |
| 30 |
* Returns the {@link ClassInfo} corresponding to this transformed class. |
| 31 |
* |
| 32 |
* @return the {@link ClassInfo} corresponding to this transformed class, never {@code null} |
| 33 |
*/ |
| 34 |
@Override |
| 35 |
ClassInfo info(); |
| 36 |
|
| 37 |
/** |
| 38 |
* Adds a marker annotation of given type to this class. |
| 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 |
ClassConfig addAnnotation(Class<? extends Annotation> annotationType); |
| 46 |
|
| 47 |
/** |
| 48 |
* Adds given annotation to this class. 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 class, must not be {@code null} |
| 52 |
* @return this configurator object, to allow fluent usage |
| 53 |
*/ |
| 54 |
@Override |
| 55 |
ClassConfig addAnnotation(AnnotationInfo annotation); |
| 56 |
|
| 57 |
/** |
| 58 |
* Adds given annotation to this class. 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 class, must not be {@code null} |
| 62 |
* @return this configurator object, to allow fluent usage |
| 63 |
*/ |
| 64 |
@Override |
| 65 |
ClassConfig addAnnotation(Annotation annotation); |
| 66 |
|
| 67 |
/** |
| 68 |
* Removes all annotations matching given predicate from this class. |
| 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 |
ClassConfig removeAnnotation(Predicate<AnnotationInfo> predicate); |
| 75 |
|
| 76 |
/** |
| 77 |
* Removes all annotations from this class. |
| 78 |
* |
| 79 |
* @return this configurator object, to allow fluent usage |
| 80 |
*/ |
| 81 |
@Override |
| 82 |
ClassConfig removeAllAnnotations(); |
| 83 |
|
| 84 |
/** |
| 85 |
* Returns a collection of {@link MethodConfig} objects for each constructor of this class, |
| 86 |
* as defined by {@link ClassInfo#constructors() ClassInfo.constructors}. |
| 87 |
* |
| 88 |
* @return immutable collection of {@link MethodConfig} objects, never {@code null} |
| 89 |
*/ |
| 90 |
Collection<MethodConfig> constructors(); |
| 91 |
|
| 92 |
/** |
| 93 |
* Returns a collection of {@link MethodConfig} objects for each method of this class, |
| 94 |
* as defined by {@link ClassInfo#methods() ClassInfo.methods}. |
| 95 |
* |
| 96 |
* @return immutable collection of {@link MethodConfig} objects, never {@code null} |
| 97 |
*/ |
| 98 |
Collection<MethodConfig> methods(); |
| 99 |
|
| 100 |
/** |
| 101 |
* Returns a collection of {@link FieldConfig} objects for each field of this class, |
| 102 |
* as defined by {@link ClassInfo#fields() ClassInfo.fields}. |
| 103 |
* |
| 104 |
* @return immutable collection of {@link FieldConfig} objects, never {@code null} |
| 105 |
*/ |
| 106 |
Collection<FieldConfig> fields(); |
| 107 |
|
| 108 |
// there's no `Collection<RecordComponentConfig> recordComponents()`, because CDI |
| 109 |
// doesn't know anything about records and treats them as plain classes |
| 110 |
} |