Debian Codegraph @

api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticComponents.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.types.Type;
14
15 /**
16 * Allows registering synthetic beans and observers.
17 *
18 * @since 4.0
19 */
20 public interface SyntheticComponents {
21 /**
22 * Creates a {@link SyntheticBeanBuilder} that allows configuring a new synthetic bean
23 * of given {@code beanClass}. The synthetic bean will be registered at the end of
24 * the {@link Synthesis @Synthesis} method.
25 *
26 * @param beanClass the bean class of the new synthetic bean, must not be {@code null}
27 * @param <T> the bean class of the new synthetic bean
28 * @return a new {@link SyntheticBeanBuilder}, never {@code null}
29 */
30 <T> SyntheticBeanBuilder<T> addBean(Class<T> beanClass);
31
32 /**
33 * Creates a {@link SyntheticObserverBuilder} that allows configuring a new synthetic observer
34 * for given {@code eventType}. The synthetic observer will be registered at the end of
35 * the {@link Synthesis @Synthesis} method.
36 *
37 * @param eventType the observed event type of the new synthetic observer, must not be {@code null}
38 * @param <T> the observed event type of the new synthetic observer
39 * @return a new {@link SyntheticObserverBuilder}, never {@code null}
40 */
41 <T> SyntheticObserverBuilder<T> addObserver(Class<T> eventType);
42
43 /**
44 * Creates a {@link SyntheticObserverBuilder} that allows configuring a new synthetic observer
45 * for given {@code eventType}. The synthetic observer will be registered at the end of
46 * the {@link Synthesis @Synthesis} method.
47 * <p>
48 * This method is supposed to be called with explicitly provided type arguments. For example,
49 * to define a synthetic observer of event type {@code List<String>}, one would call:
50 * <pre>{@code
51 * // types is of type Types
52 * // syntheticComponents is of type SyntheticComponents
53 * syntheticComponents.<List<String>>addObserver(types.parameterized(List.class, String.class))
54 * ...
55 * }</pre>
56 *
57 * @param eventType the observed event type of the new synthetic observer, must not be {@code null}
58 * @param <T> the observed event type of the new synthetic observer
59 * @return a new {@link SyntheticObserverBuilder}, never {@code null}
60 */
61 <T> SyntheticObserverBuilder<T> addObserver(Type eventType);
62 }