value
Returns an identifier for an Assisted parameter.
Within an Inject 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 Inject constructor:
@Assisted foo: Foo
@Assisted("") foo: Foo
Within an AssistedFactory method, each parameter must match an Assisted parameter in the associated Inject 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:
class DataService(
bindingFromDagger: BindingFromDagger,
@Assisted name: String,
@Assisted("id") id: String,
@Assisted("repo") repo: String,
)
@AssistedFactory
fun interface DataServiceFactory {
fun create(
name: String,
@Assisted("id") id: String,
@Assisted("repo") repo: String,
): DataService
}
Content copied to clipboard