• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (C) 2007 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.assistedinject;
18 
19 import static java.lang.annotation.ElementType.CONSTRUCTOR;
20 import static java.lang.annotation.RetentionPolicy.RUNTIME;
21 
22 import com.google.inject.Inject;
23 
24 import java.lang.annotation.Retention;
25 import java.lang.annotation.Target;
26 
27 /**
28  * <p>
29  * When used in tandem with {@link FactoryModuleBuilder}, constructors annotated with
30  * {@code @AssistedInject} indicate that multiple constructors can be injected, each with different
31  * parameters. AssistedInject annotations should not be mixed with {@literal @}{@link Inject}
32  * annotations. The assisted parameters must exactly match one corresponding factory method within
33  * the factory interface, but the parameters do not need to be in the same order. Constructors
34  * annotated with AssistedInject <b>are</b> created by Guice and receive all the benefits
35  * (such as AOP).
36  *
37  * <p>
38  * <strong>Obsolete Usage:</strong> When used in tandem with {@link FactoryProvider}, constructors
39  * annotated with {@code @AssistedInject} trigger a "backwards compatibility mode". The assisted
40  * parameters must exactly match one corresponding factory method within the factory interface and
41  * all must be in the same order as listed in the factory. In this backwards compatable mode,
42  * constructors annotated with AssistedInject <b>are not</b> created by Guice and thus receive
43  * none of the benefits.
44  *
45  * <p>
46  * Constructor parameters must be either supplied by the factory interface and marked with
47  * <code>@Assisted</code>, or they must be injectable.
48  *
49  * @author jmourits@google.com (Jerome Mourits)
50  * @author jessewilson@google.com (Jesse Wilson)
51  */
52 @Target( { CONSTRUCTOR })
53 @Retention(RUNTIME)
54 public @interface AssistedInject {
55 }
56