Annotation Interface Assisted


@Documented @Retention(RUNTIME) @Target(PARAMETER) public @interface Assisted
Annotates a parameter within an AssistedInject-annotated constructor.

See AssistedInject.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Returns an identifier for an Assisted parameter.
  • Element Details

    • value

      String value
      Returns an identifier for an Assisted parameter.

      Within an AssistedInject constructor, each Assisted parameter must be uniquely defined by the combination of its identifier and type. If no identifier is specified, the default identifier is an empty string. Thus, the following parameters are equivalent within an AssistedInject constructor:

      • @Assisted Foo foo
      • @Assisted("") Foo foo

      Within an AssistedFactory method, each parameter must match an Assisted parameter in the associated AssistedInject constructor (i.e. identifier + type). A parameter with no @Assisted annotation will be assigned the default identifier. Thus, the following parameters are equivalent within an AssistedFactory method:

      • Foo foo
      • @Assisted Foo foo
      • @Assisted("") Foo foo

      Example:

      
       final class DataService {
         @AssistedInject
         DataService(
             BindingFromDagger bindingFromDagger,
             @Assisted String name,
             @Assisted("id") String id,
             @Assisted("repo") String repo) {}
       }
      
       @AssistedFactory
       interface DataServiceFactory {
         DataService create(
             String name,
             @Assisted("id") String id,
             @Assisted("repo") String repo);
       }
       
      Default:
      ""