blob: 7fa96c9e932cf19aab57f5433aaf658bc60c6ac8 [file] [log] [blame]
crazyboblee66b415a2006-08-25 02:01:19 +00001/**
2 * Copyright (C) 2006 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.google.inject;
18
crazyboblee698a6c82007-02-13 21:55:29 +000019import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
kevinb9na99dca72007-02-11 04:48:57 +000020import static java.lang.annotation.ElementType.CONSTRUCTOR;
21import static java.lang.annotation.ElementType.FIELD;
22import static java.lang.annotation.ElementType.METHOD;
crazyboblee66b415a2006-08-25 02:01:19 +000023import java.lang.annotation.Retention;
kevinb9na99dca72007-02-11 04:48:57 +000024import static java.lang.annotation.RetentionPolicy.RUNTIME;
crazyboblee66b415a2006-08-25 02:01:19 +000025import java.lang.annotation.Target;
26
27/**
crazyboblee4602a6f2007-02-15 02:45:18 +000028 * <p>Annotates members which should have their value[s] injected.
29 *
30 * <p>Also applies to other annotations which can be used with {@link Key}s and
31 * at injection points.
crazyboblee66b415a2006-08-25 02:01:19 +000032 *
33 * @author crazybob@google.com (Bob Lee)
34 */
crazyboblee4602a6f2007-02-15 02:45:18 +000035@Target({ METHOD, CONSTRUCTOR, FIELD, ANNOTATION_TYPE })
crazyboblee66b415a2006-08-25 02:01:19 +000036@Retention(RUNTIME)
37public @interface Inject {
38
39 /**
crazyboblee4602a6f2007-02-15 02:45:18 +000040 * Indicates whether injection at the target is optional or not. The default
41 * is {@code false}. Can be used on methods and fields. If a method has
42 * multiple parameters and one parameter binding is missing, the method
43 * won't be invoked at all. Not applicable to constructors or other
44 * annotations.
crazyboblee66b415a2006-08-25 02:01:19 +000045 */
crazyboblee4602a6f2007-02-15 02:45:18 +000046 boolean optional() default false;
crazyboblee66b415a2006-08-25 02:01:19 +000047}