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