@Documented @Target(value=METHOD) @Retention(value=RUNTIME) @Beta public @interface Multibinds
You can declare that a multibound set or map is bound by annotating an abstract module method
that returns the set or map you want to declare with @Multibinds
.
You do not have to use @Multibinds
for sets or maps that have at least one
contribution, but you do have to declare them if they may be empty.
@Module abstract class MyModule {
@Multibinds Set<Foo> aSet();
@Multibinds @MyQualifier Set<Foo> aQualifiedSet();
@Multibinds Map<String, Foo> aMap();
@Multibinds @MyQualifier Map<String, Foo> aQualifiedMap();
@Provides
static Object usesMultibindings(Set<Foo> set, @MyQualifier Map<String, Foo> map) {
return …
}
}
A given set or map multibinding can be declared any number of times without error. Dagger
never implements or calls any @Multibinds
methods.
Copyright © 2012���2017 The Dagger Authors. All rights reserved.