crazyboblee | 66b415a | 2006-08-25 02:01:19 +0000 | [diff] [blame] | 1 | /** |
| 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 | |
| 17 | package com.google.inject; |
| 18 | |
crazyboblee | 698a6c8 | 2007-02-13 21:55:29 +0000 | [diff] [blame] | 19 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; |
kevinb9n | a99dca7 | 2007-02-11 04:48:57 +0000 | [diff] [blame] | 20 | import static java.lang.annotation.ElementType.CONSTRUCTOR; |
| 21 | import static java.lang.annotation.ElementType.FIELD; |
| 22 | import static java.lang.annotation.ElementType.METHOD; |
crazyboblee | 66b415a | 2006-08-25 02:01:19 +0000 | [diff] [blame] | 23 | import java.lang.annotation.Retention; |
kevinb9n | a99dca7 | 2007-02-11 04:48:57 +0000 | [diff] [blame] | 24 | import static java.lang.annotation.RetentionPolicy.RUNTIME; |
crazyboblee | 66b415a | 2006-08-25 02:01:19 +0000 | [diff] [blame] | 25 | import java.lang.annotation.Target; |
| 26 | |
| 27 | /** |
crazyboblee | 4602a6f | 2007-02-15 02:45:18 +0000 | [diff] [blame^] | 28 | * <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. |
crazyboblee | 66b415a | 2006-08-25 02:01:19 +0000 | [diff] [blame] | 32 | * |
| 33 | * @author crazybob@google.com (Bob Lee) |
| 34 | */ |
crazyboblee | 4602a6f | 2007-02-15 02:45:18 +0000 | [diff] [blame^] | 35 | @Target({ METHOD, CONSTRUCTOR, FIELD, ANNOTATION_TYPE }) |
crazyboblee | 66b415a | 2006-08-25 02:01:19 +0000 | [diff] [blame] | 36 | @Retention(RUNTIME) |
| 37 | public @interface Inject { |
| 38 | |
| 39 | /** |
crazyboblee | 4602a6f | 2007-02-15 02:45:18 +0000 | [diff] [blame^] | 40 | * 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. |
crazyboblee | 66b415a | 2006-08-25 02:01:19 +0000 | [diff] [blame] | 45 | */ |
crazyboblee | 4602a6f | 2007-02-15 02:45:18 +0000 | [diff] [blame^] | 46 | boolean optional() default false; |
crazyboblee | 66b415a | 2006-08-25 02:01:19 +0000 | [diff] [blame] | 47 | } |