001package io.avaje.inject;
002
003import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
004import static java.lang.annotation.ElementType.METHOD;
005import static java.lang.annotation.ElementType.TYPE;
006import static java.lang.annotation.RetentionPolicy.SOURCE;
007
008import java.lang.annotation.Retention;
009import java.lang.annotation.Target;
010
011/**
012 * Expresses a requirement for a bean to be wired/registered into the {@link BeanScope}.
013 *
014 * <pre>{@code
015 * @Factory
016 * public class MyAutoConfiguration {
017 *
018 *   @Bean
019 *   @Profile("test")
020 *   public MyService myService() {
021 *       ...
022 *   }
023 *
024 * }
025 *
026 * }</pre>
027 *
028 * <p>In the sample above, the MyService bean will get wired only if <code>avaje.profiles</code> is
029 * set to "test" in the {@link io.avaje.inject.spi.ConfigPropertyPlugin}.
030 *
031 * <p>Avaje Config provides an implementation and if it is included in the classpath then Avaje
032 * Config will be used to test the property conditions.
033 *
034 * <p>If no ConfigPropertyPlugin is found then the default implementation is used which uses
035 * {@link System#getProperty(String)} and {@link System#getenv(String)}.
036 */
037@Retention(SOURCE)
038@Target({TYPE, METHOD, ANNOTATION_TYPE})
039public @interface Profile {
040
041  /**
042   * Expresses that any of the given profiles must be set for the bean to load.
043   *
044   * @return the property to check
045   */
046  String[] value() default {};
047
048  /**
049   * Expresses that all of the given profiles must be set for the bean to load.
050   *
051   * @return the property to check
052   */
053  String[] all() default {};
054
055  /**
056   * Expresses that none of the given profiles must be set for the bean to load.
057   *
058   * @return the properties to check
059   */
060  String[] none() default {};
061}