xref: /aosp_15_r20/external/jsr330/src/javax/inject/Qualifier.java (revision 3ff81872dd771505ae446579ad46cd1fa54f7475)
1*3ff81872SXin Li /*
2*3ff81872SXin Li  * Copyright (C) 2009 The JSR-330 Expert Group
3*3ff81872SXin Li  *
4*3ff81872SXin Li  * Licensed under the Apache License, Version 2.0 (the "License");
5*3ff81872SXin Li  * you may not use this file except in compliance with the License.
6*3ff81872SXin Li  * You may obtain a copy of the License at
7*3ff81872SXin Li  *
8*3ff81872SXin Li  *      http://www.apache.org/licenses/LICENSE-2.0
9*3ff81872SXin Li  *
10*3ff81872SXin Li  * Unless required by applicable law or agreed to in writing, software
11*3ff81872SXin Li  * distributed under the License is distributed on an "AS IS" BASIS,
12*3ff81872SXin Li  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*3ff81872SXin Li  * See the License for the specific language governing permissions and
14*3ff81872SXin Li  * limitations under the License.
15*3ff81872SXin Li  */
16*3ff81872SXin Li 
17*3ff81872SXin Li package javax.inject;
18*3ff81872SXin Li 
19*3ff81872SXin Li import java.lang.annotation.Target;
20*3ff81872SXin Li import java.lang.annotation.Retention;
21*3ff81872SXin Li import java.lang.annotation.Documented;
22*3ff81872SXin Li import static java.lang.annotation.RetentionPolicy.RUNTIME;
23*3ff81872SXin Li import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
24*3ff81872SXin Li 
25*3ff81872SXin Li /**
26*3ff81872SXin Li  * Identifies qualifier annotations. Anyone can define a new qualifier. A
27*3ff81872SXin Li  * qualifier annotation:
28*3ff81872SXin Li  *
29*3ff81872SXin Li  * <ul>
30*3ff81872SXin Li  *   <li>is annotated with {@code @Qualifier}, {@code @Retention(RUNTIME)},
31*3ff81872SXin Li  *      and typically {@code @Documented}.</li>
32*3ff81872SXin Li  *   <li>can have attributes.</li>
33*3ff81872SXin Li  *   <li>may be part of the public API, much like the dependency type, but
34*3ff81872SXin Li  *      unlike implementation types which needn't be part of the public
35*3ff81872SXin Li  *      API.</li>
36*3ff81872SXin Li  *   <li>may have restricted usage if annotated with {@code @Target}. While
37*3ff81872SXin Li  *      this specification covers applying qualifiers to fields and
38*3ff81872SXin Li  *      parameters only, some injector configurations might use qualifier
39*3ff81872SXin Li  *      annotations in other places (on methods or classes for example).</li>
40*3ff81872SXin Li  * </ul>
41*3ff81872SXin Li  *
42*3ff81872SXin Li  * <p>For example:
43*3ff81872SXin Li  *
44*3ff81872SXin Li  * <pre>
45*3ff81872SXin Li  *   &#064;java.lang.annotation.Documented
46*3ff81872SXin Li  *   &#064;java.lang.annotation.Retention(RUNTIME)
47*3ff81872SXin Li  *   &#064;javax.inject.Qualifier
48*3ff81872SXin Li  *   public @interface Leather {
49*3ff81872SXin Li  *     Color color() default Color.TAN;
50*3ff81872SXin Li  *     public enum Color { RED, BLACK, TAN }
51*3ff81872SXin Li  *   }</pre>
52*3ff81872SXin Li  *
53*3ff81872SXin Li  * @see javax.inject.Named @Named
54*3ff81872SXin Li  */
55*3ff81872SXin Li @Target(ANNOTATION_TYPE)
56*3ff81872SXin Li @Retention(RUNTIME)
57*3ff81872SXin Li @Documented
58*3ff81872SXin Li public @interface Qualifier {}
59