com.google.inject.assistedinject.AssistedInject Maven / Gradle / Ivy
/*
* Copyright (C) 2007 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.inject.assistedinject;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import com.google.inject.Inject;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* When used in tandem with {@link FactoryModuleBuilder}, constructors annotated with
* {@code @AssistedInject} indicate that multiple constructors can be injected, each with different
* parameters. AssistedInject annotations should not be mixed with {@literal @}{@link Inject}
* annotations. The assisted parameters must exactly match one corresponding factory method within
* the factory interface, but the parameters do not need to be in the same order. Constructors
* annotated with AssistedInject are created by Guice and receive all the benefits (such as
* AOP).
*
* Obsolete Usage: When used in tandem with {@link FactoryProvider},
* constructors annotated with {@code @AssistedInject} trigger a "backwards compatibility mode". The
* assisted parameters must exactly match one corresponding factory method within the factory
* interface and all must be in the same order as listed in the factory. In this backwards
* compatable mode, constructors annotated with AssistedInject are not created by Guice and
* thus receive none of the benefits.
*
*
Constructor parameters must be either supplied by the factory interface and marked with
* @Assisted
, or they must be injectable.
*
* @author [email protected] (Jerome Mourits)
* @author [email protected] (Jesse Wilson)
*/
@Target({CONSTRUCTOR})
@Retention(RUNTIME)
public @interface AssistedInject {}